Connecting Tech Pros Worldwide Help | Site Map

Applet Problam

Newbie
 
Join Date: Oct 2009
Posts: 1
#1: 4 Weeks Ago
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("Calculate");
Font font =new Font("Helvetica",Font.BOLD,18);
int num,sum=0;
String s;
@Override
public void init()
{
enter.setFont(font);
result.setFont(font);
calc.addActionListener(this);
text.addActionListener(this);

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

}
public void start()
{
text.setText("0");
}
public void actionPerformed(ActionEvent e)
{
num=Integer.parseInt(text.getText());
sum +=num;
s=String.valueOf(sum);
output.setText("0");
text.setText("0");
if(num<0)
calc.setEnabled(false);

}

}
Newbie
 
Join Date: May 2009
Posts: 23
#2: 4 Weeks Ago

re: Applet Problam


I'm no expert with applets 'n ActionListeners, but I think you need to change
Expand|Select|Wrap|Line Numbers
  1. public class test1 extends Applet
to
Expand|Select|Wrap|Line Numbers
  1. public class test1 extends Applet implements ActionListener
Kinda hard to say more until you explain what your applet is supposed to do.
Reply