Applet Problam

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dolati1703
    New Member
    • Oct 2009
    • 1

    Applet Problam

    hi dear
    i have problem in this code
    it is very important for me please send your answers very Quicly.



    import java.applet.*;
    import java.awt.*;
    import java.awt.event. ActionListener;

    public class test1 extends Applet
    {
    Label enter =new Label("Enter Number 1");
    Label result =new Label("Sum Is:");
    TextField text=new TextField(5);
    TextField output=new TextField(5);
    Button calc=new Button("Calcula te");
    Font font =new Font("Helvetica ",Font.BOLD,18) ;
    int num,sum=0;
    String s;
    @Override
    public void init()
    {
    enter.setFont(f ont);
    result.setFont( font);
    calc.addActionL istener(this);
    text.addActionL istener(this);

    add(enter);
    add(text);
    add(result);
    add(output);
    add(calc);

    }
    public void start()
    {
    text.setText("0 ");
    }
    public void actionPerformed (ActionEvent e)
    {
    num=Integer.par seInt(text.getT ext());
    sum +=num;
    s=String.valueO f(sum);
    output.setText( "0");
    text.setText("0 ");
    if(num<0)
    calc.setEnabled (false);

    }

    }
  • mrjohn
    New Member
    • May 2009
    • 31

    #2
    I'm no expert with applets 'n ActionListeners , but I think you need to change
    [code="java]public class test1 extends Applet[/code]
    to
    [code="java]public class test1 extends Applet implements ActionListener[/code]

    Kinda hard to say more until you explain what your applet is supposed to do.

    Comment

    Working...