Applet font

Is there possible to have multi-font in a text area in an applet
Claude

/*Create new fonts*/
Font font1=new Font(String name,
int style,
int size);
Font font2=new Font(String name,
int style,
int size);
/*Set new font on a Graphics object*/
public void paint(Graphics g){
g.setFont(font1);
/*drawString with graphics object*/
g.drawString(String str,int x, int y);
g.setFont(font2);
g.drawString(String str,int x, int y);
}

Similar Messages

  • Applet font not changed

    Hello,
    I have an application/applet that displays persian text. The font is bundled in the jar file and this works perfectly well when I run the application, however the applet seems to display a some default persion font (which does not join characters correctly) and not the font bundled in the jar file.
    I wanted to know if it is possible for an applet to use a font that is bundled in its jar file or is the applet constrained to using fonts that are avaibale to the browser only?
    Thanks,
    Hoos

    Fonts are embedded in the PDF part of an AI file. So you can use any AI file with embedded fonts to place into InDesign and to Print from it.
    But when you want to edit the file in Illustrator you have to have the needed fonts installed on your Computer (and of course licenced). Otherwise you will experience what you have described.
    If you don't need to edit the file, place it as it is in InDesign or whatelse program you work with.

  • Default applet font

    Hi,
    I want to change the default font for my applet so that everything
    within the applet will use this font.
    Does anyone know how to do this ?
    Thanks
    Sue

    Ok sub class Container,
    set the font on this new SuesFontyContainer
    overide the add method, in the new add method take the font and set it to the component added, call supr.add with the component.
    Now set the content pane of the applet with this new container.
    Voila
    this will work on one level, ie if you add a component to a panel and add the panel it wont work on the component but thats where SuesFontyPanel can come in!

  • Applet font problem between linux and windows

    I just want to share my experience in several project i've taken part.
    In some projects, where all are developed under linux environment (suse 9.2),
    we use jasper report for report generation and use the web applet for our clients to print.
    They print ok in linux env, with the netscape 7.1, courier 10 font and jvm 1.4.2_06b version.
    But when accessed from windows env, with the same browser and the same jvm version, the applet and the print out are different from those of lin env. The headers and footers are missing. When the we edit/lower the header and footer size at the jasper report file, then they appears @ the window env.
    So strange that the font handling between win and lin differ (still my assumption). I'vent been able to solve this problem totally since the client must stick with one OS else the print out will be different.
    Quite dissatisfied, coz i really think i could code once the report and run it anywhere in the applet and behaves in the same way.
    Could anybody help ? T-T
    Regards,
    Albert Gan

    hi!
    this is my first post and i would like to ask if how did you create the web applet printing. im totally new to java and i dont know where to start.
    i hope that you can guide me or give me some instructions. thanks in advance =)

  • Java Applets font rendering with no AA

    So I've exhausted all possibilities on my end here and have no idea how to get anti aliasing to work with java applets. I've followed all of the suggestions from the wiki entry for the subject here:
    https://wiki.archlinux.org/index.php/Ja … ment_Fonts
    I've attached a screenshot of a few browsers and the appletviewer running a script from a book I am following at the moment. It's consistent, but it's an itch I haven't been able to scratch. OCD at it's finest here. It doesn't halt production or anything, but it bugs me.
    Thanks for any help offered!
    http://cigii.com/javajunk.png
    Moderator Edit:  Redacted in-line picture and converted it to a url link
    Last edited by ewaller (2011-12-01 04:13:44)

    transmutated:
    The picture in your original post was well beyond the size permitted by our policy.  If you would like to include a thumbnail picture, go ahead and edit that post with image tags that point to the thumbnail inside the url tags.  Have the url tags point at the big picture.  That way your readers can see the thumbnail and click through it to see the full image.
    Thanks

  • Java Applets and Packages

    Hi
    I have been having problems calling my own packages in java applets to no avail
    For a basic example i am storing graphics in a package called graphics and i have a class with a drawline function.
    How would i call this in my main program?
    At the top of the code i have imported the correct package using import useful.oh;
    I have tried the "oh oh = new oh();" which does not cause any compile errors however it doesnt result in a line on screen.
    I have also tried the oh.doIt(); function as suggested in some books, but java seems to dislike this and say it cannot find symbol doIt()
    Any help would be greatly appreciated!
    Excuse the formatting
    Thanks
    J Selby
    The package code:
    package useful;
    import java.util.*;
    import java.lang.*;
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    public class oh {
    public void paint(Graphics g) {
    g.drawRect(100,50,200,50);
    The applet code:
    //Declare Java Libraries
    import useful.*;
    import java.lang.*;
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    public class calculator extends Applet
         Font screen = new Font("Tahoma", Font.BOLD, 11);
         public void init()
         // Set null layout - Gives freedom for button placement
         setSize(400,400);
         setBackground(new Color(36, 48, 74));
         setLayout(null);
    Button exit = new Button("Exit");
         Button go = new Button("Go");
         add(exit);
         exit.setLocation(155,10);
              exit.setSize(40,22);
    add(go);
         go.setLocation(120,10);
         go.setSize(25,22);
    Choice tech=new Choice();
    tech.addItem("Tutorial Menu");
    tech.addItem("Applet A");
    tech.addItem("Applet B");
    tech.addItem("Applet C");
    tech.addItem("Applet D");
    tech.addItem("Applet E");
    tech.addItem("Java Quiz");     
    add(tech);
         tech.setLocation(10,10);
         oh oh = new oh();

    From your code it is no where written that you are using the package called graphics
    You are been using
    package useful;
    this implies u r using the package called useful
    well let me tell you how to use packages.
    For example if you use a package called pack1
    then that file you need to compile from parent directory as
    javac -d filename.java
    this will give you the folder called pack1 and the compiled file placed in it..
    so to use this in other folder from parent directory then
    you have to import that file
    import pack1.filename;
    then this will allow you to acess all the methods from that class file..
    i hope you get me if any concerns can mail me at
    [email protected]

  • Problems with applet - no text in the window

    Hi!
    I'm trying to learn some java, and I've just done my first applet. The code looks like this:
    import java.awt.*;
    import java.applet.*;
    public class MittNamnApplet extends Applet {
    Font f;
    public void init() {
    f = new Font("SansSerif", Font.BOLD, 24);
    setBackground(Color.pink);
    public void pain (Graphics g) {
    g.setFont(f);
    //g.setColor(Color.blue);
    // g.drawString("Habibi", 45,100);
    And then I made an html code that looks like this:
    <html>
    <applet code="MittNamnApplet.class" height=200 width=320>
    </applet>
    </html>
    When I run it with appletviewer in Command prompt there is only a pink squre coming up, where is the text??? Why? Can someone please help a dummie?
    Thanks ;-)

    The method name should be "paint", not "pain".
    And you have commented out the g.drawstring statement, so it doesn't draw your name.

  • Displaying Applet in JSP Using jsp:plugin tag

    The following code is not working eventhough i downloaded to JRE plug-in .Please help me to work the
    following code in JSP.
    <jsp:plugin code="mani.Clock2.class"
    codebase="/classes/" width=300 height=300
    jreversion="1.3"
    nspluginurl="http://java.sun.com/products/plugin/1.1.3/plugin-install.html"
    iepluginurl="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0">
    <jsp:fallback>
    <font color=#FF0000 size=10>Sorry Error While Loading Applet </font>
    </jsp:fallback>
    </jsp:plugin>

    why don't ypu just use the <applet> tag?

  • APPLETS and ACESSING FILES

    The following is my code. I want to be able to search the flat text data file for inputed query. I have managed to do it one way with out applet wise, but I had to use URL. I creates the URL but get stuck on the BufferReader more specifically the openStream method I think. Now the file I am trying to access is on the server which is behind a firewall.
    any good suggestions or even new aproaches are welcomed
    import java.awt.*;
    import java.applet.*;
    import java.lang.*;
    import java.lang.Object;
    import java.io.*;
    import java.net.URL;
    public class Goin extends Applet {
         Font f = new Font("Georgia",Font.BOLD,36);
         public void init() {
                   try{
                             System.out.println("we are in");
                             URL yahoo = new URL("http://www.nj.gov/military/test/testme.txt");
                             System.out.println("assigned url");
                        BufferedReader in = new BufferedReader(new InputStreamReader(yahoo.openStream()));
                        System.out.println("created buffer");
                        String line = in.readLine();
                        System.out.println("we read one line");
                        while ( line != null )
                             System.out.println("we are in for a while");
                             line = in.readLine();
                             int index = line.indexOf("t");
                             if ( index != -1)
                                  System.out.println("we are in if");
                                  System.out.println(line);
                                  System.out.println("we are out if");
                             System.out.println("we are out for a while");
                        in.close();      
                        }catch (IOException e)
                        {System.out.println("Error -- " + e.toString());}     
                        System.out.println("we are finishing");}

    they do but you have to use what i have except you may have to specify other things. Actually I just found out that the url I used is down so that may be the problem.

  • Simple applet compiling error

    Hi!
    I feel very embarrassed to ask this question:
    This is an applet that returns 1 error after compiling:
    /* an applet which uses Times Roman italic and bold font, 28 point size, drawn green on a yellow background*/
    import java.awt.Graphics;
    import java.awt.Font;
    import java.awt.Color;
    public class Lesson7Applet extends java.applet.Applet
         Font f = new Font("TimesRoman", Font.BOLD, Font.ITALIC, 28);
         public void paint (Graphics g)
              g.setFont (f);
              g.setColor(Color.green);
              setBackground(Color.yellow);
              g.drawString("Lesson 7 was easy", 10, 30);
    Error message after compiling:
    C:\java>javac Lesson7Applet.java
    Lesson7Applet.java:7: cannot resolve symbol
    symbol : constructor Font (java.lang.String,int,int,int)
    location: class java.awt.Font
    Font f = new Font("TimesRoman", Font.BOLD, Font.ITALIC, 28);
    1 error (pointing at "new")
    Could anyone help!
    Much obliged
    emni

    Hi emni!
    It's simple:
    Font f = new Font(
    "TimesRoman", // font name
    Font.BOLD & Font.ITALIC, // font style
    28); // font size
    Best regards.

  • Blank Applet

    Hi there!...
    I wrote this java code and see how an applet works. But When I try to view it through Internet Explorer version 6.0.2800.1106 I can only see a gray square and nothing else.
    I'm working with Win2k Pro. and j2dsk1.4. All my files are located in the same path.
    Can anyone tell me If I need an extra configuration or what's really going on here?
    JAVA CODE:
    import java.awt.Font;
    import java.awt.Graphics;
    import java.awt.Color;
    import java.applet.Applet;
    public class Palindrome extends Applet {
    Font f = new Font("TimesRoman",Font.BOLD,25);
    public void paint(Graphics screen){
    screen.setFont(f) ;
    screen.setColor(Color.red);
    screen.drawString("HI WORLD!",50,25);
    }//Fin m�todo paint
    }//Fin clase Palindrome
    HTML CODE:
    <html>
    <head>
    <title>Documento sin t�tulo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <applet code="Palindrome.class" width="400" height="300">
    </applet></body>
    </html>

    use the HtmlConverter.exe in the jdk bin directory to convert your html page with the
    correct tag for applet (wich is object NOT the depreciated applet).
    Than check the trace if it still doesn't work:
    To turn the full trace on (windows) you can start the java console, to be found here:
    C:\Program Files\Java\j2re1.4...\bin\jpicpl32.exe
    In the advanced tab you can fill in something for runtime parameters fill in this:
    -Djavaplugin.trace=true -Djavaplugin.trace.option=basic|net|security|ext|liveconnect
    if you cannot start the java console check here:
    C:\Documents and Settings\userName\Application Data\Sun\Java\Deployment\deployment.properties
    I think for linux this is somewhere in youruserdir/java (hidden directory)
    add or change the following line:
    javaplugin.jre.params=-Djavaplugin.trace\=true -Djavaplugin.trace.option\=basic|net|security|ext|liveconnect
    for 1.5:
    deployment.javapi.jre.1.5.0_03.args=-Djavaplugin.trace\=true -Djavaplugin.trace.option\=basic|net|security|ext|liveconnect
    The trace is here:
    C:\Documents and Settings\your user\Application Data\Sun\Java\Deployment\log\plugin...log
    I think for linux this is somewhere in youruserdir/java (hidden directory)
    Print out the full trace of the exception:
    try{...}catch(Exception e){e.printStackTrace();}

  • I cant get it to work! NullPointerExeption at first awt.Graphics Object

    I am writing a game with AWT having it as an applet. I intend NOT to use anything outside of Java 1.1
    For my Game i thought that i ATLEAST need the following classes:
    MainGame, Level, Unit.
    I Started writing Level. wrote a fewe methods for it such as
    drawGras(int grastype) And started to write MainGame to see if they would work together. it's is/is going to be my first Java application where i actually know what object orienting is... I have already wrote a game in Java but with out knowing what a class or what object orienting realy is(the game works rather good to) but this time i wanted to use object orienting but came up with problems =( if first posted in "New to Javaprogramming" but they couldn't help me and advice me here
    My previous post: http://forum.java.sun.com/thread.jsp?forum=54&thread=290558
    Here's my code:
    import java.awt.*;
    public class MainGame extends java.applet.Applet
         implements Runnable {
         Thread runner;
         Image ImgLevel, ImgUnit;
         public MainGame() {
              Level nr1 = new Level();
              nr1.init();
              nr1.setGround(300);
              nr1.drawGras(1);
              nr1.CalcGraphics();
              nr1.drawSky(1);
              Image ImgLevel = nr1.getLevelImage();
         public void paint(Graphics g) {
              g.drawImage(ImgLevel,0,0,this);
         public void update(Graphics g) {
              paint(g);
         public void init() {
              MainGame Game = new MainGame();
         public void stop() {
              runner = null;
              System.exit(1);
         public void start() {
              if(runner == null) {
                   runner = new Thread(this);
                   runner.start();
         void Pause(int time) {
             try {
                 Thread.sleep(time);
             } catch(InterruptedException e) {
               System.out.println(e.toString());
         public void run() {
              Thread thisThread = Thread.currentThread();
                   while(thisThread == runner) {
    class Level extends java.applet.Applet {
        Font BigText = new Font("Arial", Font.PLAIN, 36);
        Font Normal = new Font("Arial", Font.PLAIN, 14);
        Font Bold = new Font("Arial", Font.BOLD, 14);
        Graphics GrLevel;
        int pattern, sky, GroundtoWalk, Ground;
        Color BgColor = new Color(166,202,240);
        Color gras1 = new Color(0,255,0);
        Color gras2 = new Color(0,200,0);
        Color gras3 = new Color(0,100,0);
        Image ImgLevel;
        void setBgColor(int r, int g, int b) {
            BgColor = new Color(r,g,b);
        void CalcGraphics() {
            ImgLevel = createImage(800,600);
            GrLevel = ImgLevel.getGraphics();
        void setGround(int GrounD) {
            Ground = GrounD;
        void GroundToWalkADD(int addToGround) {
            GroundtoWalk = Ground + addToGround;
        void setGroundToWalk(int GrToWalk) {
            GroundtoWalk = GrToWalk;
        public void init() {
              System.out.println("Init 1"); // This was placed here when i was checking how far it got when debuging
              CalcGraphics();
              System.out.println("Init 2");
              drawGras(1);
              System.out.println("Init 3");
              repaint();
              System.out.println("Init 4");
        Image getLevelImage() {
            return ImgLevel;
        public void paint(Graphics g) {
              g.drawImage(ImgLevel,0,0,this);
        public void update(Graphics g) {
            paint(g);
        void drawGras(int pt) {
         GrLevel.setColor(BgColor);
         GrLevel.fillRect(0,0,800,600);
         switch(pt) {
              case 1:
                   GrLevel.setColor(gras1);
                   GrLevel.fillRect(0,GroundtoWalk,800,300);
                   GrLevel.setClip(0,GroundtoWalk,800,300);
                   for(int i = 0; 890>i;i=i+5) {
                        GrLevel.setColor(gras2);
                        GrLevel.drawLine(0+i,GroundtoWalk,-190+i,GroundtoWalk+300);
                   for(int i=950; 0<i; i=i-5) {
                        GrLevel.setColor(gras3);
                        GrLevel.drawLine(890-i,GroundtoWalk,1000-i,GroundtoWalk+300);
              break;
              case 2:
                   GrLevel.setColor(gras2);
                   GrLevel.fillRect(0,GroundtoWalk+5,800,300);
                   for(int i = 0; 890>i;i=i+5) {
                        GrLevel.setColor(gras3);
                        GrLevel.drawLine(0+i,GroundtoWalk,-190+i,GroundtoWalk+300);
                   for(int i=950; 0<i; i=i-5) {
                        GrLevel.setColor(gras1);
                        GrLevel.drawLine(890-i,GroundtoWalk,1000-i,GroundtoWalk+300);
              break;
              case 3:
                   GrLevel.setColor(gras3);
                   GrLevel.fillRect(0,GroundtoWalk+10,800,300);
                   for(int i = 0; 800>i; i=i+20) {
                        GrLevel.fillArc(0+i,GroundtoWalk,20,20,180,-180);
              break;
         pattern = pt;
        int getGrasPattern() {
             return pattern;
        void drawSky(int cl) {
                GrLevel.setColor(BgColor);
                GrLevel.fillRect(0,0,800,155);
                switch(cl) {
                    case 1:
                   for(int y = 0;y<7;y++) {
                   for(int x = 0;x<800;x=x+20) {
                                GrLevel.setColor(Color.white);
                                GrLevel.drawArc(x,y*20,20,20,180,180);
                                GrLevel.setColor(Color.red);
                                GrLevel.drawArc(x,y*20+4,20,20,180,180);
                                GrLevel.setColor(Color.yellow);
                                GrLevel.drawArc(x,y*20+2,20,20,180,180);
                                GrLevel.setColor(Color.green);
                                GrLevel.drawArc(x,y*20+8,20,20,180,180);
                                GrLevel.setColor(Color.blue);
                                GrLevel.drawArc(x,y*20+12,20,20,180,180);
                                GrLevel.setColor(Color.pink);
                                GrLevel.drawArc(x,y*20+16,20,20,180,180);
              break;
              case 2:
                        GrLevel.setColor(Color.gray);
              break;
         sky = cl;
         GrLevel.setFont(BigText);
         GrLevel.setColor(Color.black);
         GrLevel.fillRect(0,0,800,50);
         GrLevel.setColor(Color.white);
         GrLevel.drawString("Score Tabel - comming someday",((size().width)/2)-260, 40);
        int getSkyTyp() {
             return sky;
    }I tested running the code of class Level by puting it into Level.java and compiled it...ran it with appletviewer and it worked as it was intended to.
    But when i compiled it with MainGame... and in the HTML started MainGame.class,.....applet didn't intializeand i got the following error messege:
    Init 1
    java.lang.NullPointerException
            at Level.CalcGraphics(MainGame.java:84)
            at MainGame.<init>(MainGame.java:11)Line 82: void CalcGraphics() {
    Line 83: ImgLevel = createImage(800,600);
    Line 84: GrLevel = ImgLevel.getGraphics(); // The First awt.Graphics object
    Line 85: }
    Line 9:      public MainGame() {
    Line 10:     Level nr1 = new Level();
    Line 11:     nr1.CalcGraphics(); // calling the method above -> same error first awt.Graphics Object.
    If i change it os that "drawGras" comes first it's first awt.Graphics Line will show the same error
    Hope some one can and will help me

    As per the documentation of
    java.awt.Component.createImage(int,int):
    Creates an off-screen drawable image to be used for
    double buffering.
    Parameters:
    width - the specified width
    height - the specified height
    Returns:
    an off-screen drawable image, which can be used for
    double buffering. The return value may be null if the
    component is not displayable. This will always happen
    if GraphicsEnvironment.isHeadless() returns true.
    Since:
    JDK1.0 its not
    ImgLevel = createImage(800,600); that's making the problem but The first awt.Graphics Object in class Level, no mather which on it is =((
    >
    The key part is '...may be null if the component is
    not displayable.'
    You should put your graphics initialization code in
    start(), which will be called when your applet is
    ready to go. Before then, your applet is not
    displayable. (Also, remember to dispose() your
    graphics in your stop() method, if not sooner.)for the part writen above...I'll try to change it like you are saying.
    Thanx for your help!

  • Event handling for loop??

    Hi all,
    Been busy making this budget applet and have run into some trouble with my JTable. Each time a user inputs a selection, it is supposed to return values in the first column only. The next time a user inputs an amount, it should go into the next column, etc. As of now, the user inputs an amount and returns the values in all the columns.....How do i get the column # to increase each time a user inputs an amount? thanks!
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.text.NumberFormat;
    import java.util.Arrays;
    import java.util.EventListener;
    import javax.swing.table.*;
    import javax.swing.border.Border;
    import javax.swing.border.LineBorder;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.JScrollPane;
    //WRITE FOR LOOP..COLUMNS ++1 EACH TIME AN INPUT IS ENTERED..LAST COLUMN==TOTALS
    public class ProjectOne extends JApplet implements ActionListener , ItemListener, EventListener {
         private static String Enter = "Enter";
         private JPasswordField pass;
         JLabel money, inlabel, outlabel,result, taxwitheld, taxlabelsouth, quote, information;
         JButton input, cleartable, clear;
         Image img, butimg;
         JPanel top, left, bottom, middletop, east;
         ImageIcon arg;
         JRadioButton jrbyes, jrbno;
         ButtonGroup radgroup;
         JTextField moneyinput;
         String[] tableheadings = {"CATAGORIES","1", "2", "3","4","5", "TOTALS"};
         Object data[] [] = { { "Rent","","","","","",""},
                             {"Utilities","","","","","",""},
                             {"Groceries","","","","","",""},
                             {"Clothes","","","","","",""},
                             {"Bills","","","","","",""},
                             {"Automobile","","","","","",""},
         JScrollPane sp;
         JTable table;
         public void init()
              setLayout(new BorderLayout());
              setSize(850, 325);
              doNside();
              doEside();
              doWside();
              doSside();
              doCenter();     
         public void doNside()
              img = getImage( getCodeBase( ), "money-symbol.jpg" );
              arg = new ImageIcon(img);
              money = new JLabel("<HTML><FONT COLOR=GREEN>Alan Reno's Budget Applet               </FONT>", arg ,JLabel.RIGHT );
              money.setHorizontalTextPosition(JLabel.LEFT);
              top = new JPanel( new FlowLayout( ) );
              top.setBorder(BorderFactory.createLineBorder(Color.black));
              top.setBackground(Color.WHITE);
              top.add( money );
              add( top, BorderLayout.NORTH );
         public void doSside()
              bottom = new JPanel (new FlowLayout());
              taxwitheld = new JLabel("Display Taxes Witheld?", JLabel.CENTER);
              jrbyes = new JRadioButton ("yes");
              jrbno = new JRadioButton ("no");
              jrbyes.setOpaque(false);
              jrbno.setOpaque(false);
              jrbyes.addItemListener(this);
              jrbno.addItemListener(this);
              radgroup = new ButtonGroup();
              radgroup.add(jrbyes);
              radgroup.add(jrbno);
              Font font = new Font("Serif", Font.ITALIC,12);
              Border border = LineBorder.createGrayLineBorder();
              taxlabelsouth = new JLabel(" tax amount ");
              taxlabelsouth.setFont(font);
              taxlabelsouth.setBorder(border);
              bottom.setBackground(Color.WHITE);
             bottom.add(taxwitheld);
             bottom.add(jrbyes);
             bottom.add(jrbno);
             bottom.add(taxlabelsouth);
             add(bottom, BorderLayout.SOUTH);
         public void doEside()
              east = new JPanel (new GridLayout(2,1));
              quote = new JLabel ("<HTML><FONT SIZE=+1><CENTER><B>\"Healthy</B>"
                     +"<BR>Wealthy</BR>"
                     +"<BR>and</BR>"
                     +"<BR>Wise\"</BR></CENTER></FONT>", JLabel.CENTER);
              east.setBackground(Color.WHITE);
              table = new JTable(data, tableheadings);
              DefaultTableModel dmodel = new DefaultTableModel(data, tableheadings)
                   public boolean isCellEditable(int row,int column)
                        return false;
              table = new JTable(dmodel);
              table.setPreferredScrollableViewportSize(new Dimension( 350,70));
              table.getColumnModel().getColumn(0).setPreferredWidth(150);
              table.getColumnModel().getColumn(1).setPreferredWidth(80);
              table.getColumnModel().getColumn(2).setPreferredWidth(80);
              table.getColumnModel().getColumn(3).setPreferredWidth(80);
              table.getColumnModel().getColumn(4).setPreferredWidth(80);
              table.getColumnModel().getColumn(5).setPreferredWidth(80);
              table.getColumnModel().getColumn(6).setPreferredWidth(90);
              table.getTableHeader();
              JScrollPane sp = new JScrollPane(table);
              east.add(quote);
              east.add(table);
              east.add(sp);
              sp.getViewport().add(table);
              add(east, BorderLayout.EAST);     
         public void doWside()
              left = new JPanel (new GridLayout(3, 1));
              inlabel = new JLabel("Enter Amount:", JLabel.RIGHT);
              outlabel = new JLabel("Enter Password to Display Information ", JLabel.RIGHT);
             result = new JLabel("Information (ENTER PASSWORD):  ", JLabel.RIGHT);
             left.setBackground(Color.WHITE);
             left.add(inlabel);
             left.add(outlabel);
             left.add(result);
              add( left, BorderLayout.WEST );
         public void doCenter()
             middletop = new JPanel( new GridLayout(3,3));
              moneyinput = new JTextField("$0.00",5);
              moneyinput.addActionListener(this);
             butimg = getImage( getCodeBase(), "button_1.gif");
              input = new JButton( new ImageIcon( butimg ));
              input.setForeground(Color.WHITE);
              input.setBorderPainted( false);
              input.setContentAreaFilled( false);
              input.setFocusPainted( false );
              input.setToolTipText("Select to input amount" );
              input.setFont(new Font("Serif", Font.BOLD, 17));
              input.addActionListener(this);
              clear = new JButton("ENTER");
              clear.addActionListener(this);
              clear.setActionCommand(Enter);
              pass = new JPasswordField(10);
              pass.setActionCommand(Enter);
              pass.addActionListener(this);
              information = new JLabel ("<HTML><FONT SIZE=-2>*********</FONT>", JLabel.CENTER);
              cleartable = new JButton("Clear Spreadsheet");
              middletop.setBackground(Color.WHITE);
              middletop.add(moneyinput);
              middletop.add(input);
              middletop.add(pass);
              middletop.add(clear);
              middletop.add(information);
              middletop.add(cleartable);
              add(middletop, BorderLayout.CENTER);
         public void actionPerformed(ActionEvent ae)
              String cmd = ae.getActionCommand();//password     
              /////////table
    ///////////ENTERAMOUNT///////////////////////////////////////////          
                   Object obj = ae.getSource();
                   if( obj == input )  
                        double d = Double.valueOf(moneyinput.getText()).doubleValue();
                        double output2 = (d/(7.38));
                        double a = d-output2;
                       NumberFormat nf = NumberFormat.getCurrencyInstance();
                        double rent = (a*(.45));
                        double utilities = (a*(.15));
                        double groceries = (a*(.10));
                        double clothes = (a*(.05));
                        double bills = (a*(.10));
                        double auto = (a*(.15));
    //HERE IS THE FOR LOOP WHERE I AM HAVING TROUBLE                 
                        for (int colindex=1; colindex<=6;colindex++)
                             table.setValueAt(nf.format(rent), 0, colindex);
                             table.setValueAt(nf.format(utilities), 1, colindex);
                             table.setValueAt(nf.format(groceries), 2, colindex);
                             table.setValueAt(nf.format(clothes), 3, colindex);
                             table.setValueAt(nf.format(bills), 4, colindex);
                             table.setValueAt(nf.format(auto), 5, colindex);
                        validate();
                        repaint();
                   //taxlabelsouth.setText(nf.format(output2));     
         

    Hello,
    *> >
    Each time a user inputs a selection, it is supposed to return values in the first column only. The next time a user inputs an amount, it should go into the next column, etc.
    As of now, the user inputs an amount and returns the values in all the columns (...)
    //HERE IS THE FOR LOOP WHERE I AM HAVING TROUBLE                 
                        for (int colindex=1; colindex<=6;colindex++)You are aware that this line iterates (loops) over all 6 columns, right? So it's kind of normal that all columns are updated...
    How do i get the column # to increase each time a user inputs an amount? thanks!To update only one column at a time, don't loop, instead keep a columnIndex as an instance variable (of the applet), and increase its value once each time you pass in this branch of code (don't loop).
    Make sure to handle wrapping the value (or whatever your business logic implies when you've filled all columns), as setting the value into a column that doesn't exist (colIndex>6) will likely throw an exception.
    N.B.:
                        validate();
                        repaint();validate() tells the applet to re-layout its children: this is not useful if you haven't added/removed/"resized" any children.
    repaint() tells the applet to repaint itslef. Only the Jtable needs to be repainted, IMHO, and I think a repaint() command is already done automatically during the setValue(...) call, so it's probably not necessary either.
    Hope this helps.
    Edited by: jduprez on Nov 23, 2009 11:35 AM

  • Please....help me....Weblogic and JSP

    I have the following jsp example. This jsp call a applet and set the pool and server values. This example is taken from www.weblogic.com documentation. I would like to know what is doing this jsp in the following sentence:
    <param name="weblogic_url" value="t3://localhost:7001">
    This is jsp code:
    <html>
    <head>
    <title>
    Phonebook Applet
    </title>
    </head>
    <body bgcolor=#FFFFFF>
    <font face="Helvetica">
    <h1>
    <font color=#DB1260>
    Phonebook Applet
    </font>
    </h1>
    <BLOCKQUOTE>
    This applet has been loaded using the Java 1.1.3 Plugin from a
    <font face="Courier New" size=-1><jsp:plugin></font> tag.
    The JSP servlet should have sent the appropriate browser plugin
    tags for your browser type. Try viewing the HTML source to see
    the tags, then try loading the same JSP from another browser,
    and view the HTML source again.
    </BLOCKQUOTE>
    <center>
    <jsp:plugin type="applet" code="examples.applets.PhoneBook1" codebase="/classes/"
    height="800" width="500" type="applet" jreversion="1.1.3"
    nspluginurl="http://java.sun.com/products/plugin/1.1.3/plugin-install.html"
    iepluginurl="http://java.sun.com/products/plugin/1.1.3/jinstall-113-win32.cab#Version=1,1,3,0"
    >
    <params>
    <param name="weblogic_url" value="t3://localhost:7001">
    <param name="poolname" value="demoPool">
    </params>
    <fallback>
    <font color=#FF0000>Sorry, your browser type is not supported!</font>
    </fallback>
    </jsp:plugin>
    </center>
    <p>
    <hr>
    <font size=-1>
    Copyright &copy; 1996-2000, BEA Systems, Inc. All rights reserved.
    </font>
    </font>
    </body>
    </html>
    Because I would like to call a applet and that applet does access to the DB, and i need to specify that line, but i don�t know how....before that it example i reached do the following jsp, which do a query a DB:
    <!doctype html public "-//w3c//dtd html 3.2//en">
    <html>
    <!-- Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.-->
    <head>
    <title>Query of Municipalities</title>
    </head>
    <body bgcolor=#FFFFFF>
    <font face="Helvetica">
    <h1>
    <font color=#DB1260>
    Municipalities List
    </font>
    </h1>
    <%@ page import="
    weblogic.db.jdbc.*,
    weblogic.html.*,
    java.sql.*
    " %>
    <p>
    <%
    Connection conn = null;
    try {
    Class.forName("weblogic.jdbc.pool.Driver").newInstance();
    conn = DriverManager.getConnection("jdbc:weblogic:pool:DESAPool");
    catch (Exception e) {
    e.printStackTrace();
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT * from CAT_MUNICIPIO");
    ResultSetMetaData md = rs.getMetaData();
    int numCols = md.getColumnCount();
    %>
    <p>
    <center>
    <table border=1 cellspacing=2 cellpadding=0 width=400>
    <tr>
    <%
    for (int i = 1; i <= numCols; i++) {
    %>
    <td><font face="Helvetica"><b><%= md.getColumnLabel(i) %></b></td>
    <%
    %>
    </tr>
    <%
    while (rs.next()) {
    %>
    <tr>
    <%
    for (int i = 1; i <= numCols; i++) {
    %>
    <td><font face="Helvetica"><%= rs.getString(i) %></td>
    <%
    %>
    <%
    %>
    <%
    rs.close();
    stmt.close();
    conn.close();
    %>
    <p>Please call Mary with any updates ASAP!
    <p>
    <font size=-1>Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.
    </font>
    </font>
    </body>
    </html>
    This jsp is accesible from:
    http://172.21.9.23/gep/alterno/ex_jsp/b1.jsp
    From the final jsp, I think that i have to change the following lines from the first jsp:
    <params>
    <param name="weblogic_url" value="t3://localhost:7001">
    <param name="poolname" value="demoPool">
    </params>
    by:
    <params>
    <param name="weblogic_url" value="t3://localhost:7001"> //Here is my doubt.What�s "t3:" meanning?
    <param name="poolname" value="DESAPool">
    </params>
    Could somebody help me please?.....
    Thanks in advance.....
    Mary

    look at this url you will understand
    http://www.weblogic.com/docs51/classdocs/urls.html
    n joy ....
    </ksenji>

  • Package jawa.awt does not exist

    I have searched this problem in the forum but could not find anything about it.
    I have NetBeans IDE + JDK 5.0 Update 3 installed in my computer (http://java.sun.com/j2se/1.5.0/download.jsp). But when I try to compile a very simple Java using any package I receive same error that package does not exist.
    I will be glad if someone can explain how to solve this problem.
    Regards.

    Thank you for your reply.
    The code is :
    import jawa.awt.Graphics;
    import jawa.awt.Font;
    import jawa.awt.Color;
    public class HelloAgainApplet extends java.applet.Applet{
    Font f=new Font ("TimesRoman",Font.BOLD,36);
    public void paint (Graphics g){
    g.setFont(f);
    g.setColor(COlor.red);
    g.drawString("Hello again!", 5, 50);
    And the errors are like:
    HelloAgainApplet.java:6: package jawa.awt does not exist
    import jawa.awt.Graphics;
    HelloAgainApplet.java:7: package jawa.awt does not exist
    import jawa.awt.Font;
    HelloAgainApplet.java:8: package jawa.awt does not exist
    import jawa.awt.Color;
    HelloAgainApplet.java:14: cannot find symbol
    symbol : class Font
    location: class HelloAgainApplet
    Font f=new Font ("TimesRoman",Font.BOLD,36);
    and goes on.
    Regards

Maybe you are looking for

  • No Persistence provider for EntityManager

    Hi everybody, this problem has been haunting me for days now. I have this JSE application that uses toplink essentias for his persistence layer. Everything works fine in Eclipse, but when i try to execute it outside eclipse i get the following error:

  • Vacation Rule works for ALL but not for particular notification in Item typ

    Hi, I have a situation where Vacation Rule is Ignored when choose the select option in notification page of vacation rule and notifications were being sent to Original Approver (who created the vacation Rule) instead of delegate. Vacation rule is wor

  • Found a bug in Mail 4.4

    I was checking the options at the bottom right of the screen and then a prompt to enter my account password popped up. I could only select "ok" to the prompt and could not type anything into the password query. I had to select "ok" without a password

  • Tutorial link

    Hi I need some tutorial for JDBC and XML together or how to manipulate data which comes from some database in xml. If anybody knows any utorial please let me know. Regards Preeti

  • Multi-User Support

    I have all of my photos saved on a file server in my house.  I am using Photoshop Elements 11 on my desktop to catalog all of my photos. I am doing things like tagging photos and the people recogonition features.  If I install Photoshop Elements on m