import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class Addition extends Applet implements ActionListener{
Label lbl1,lbl2;
TextField tf1,tf2;
int num,sum;
String s;
public void init()
{ sum=0;
lbl1=new Label("Doste enan akeraio kai pathste Entre:");
add(lbl1);
tf1=new TextField(10);
add(tf1);
tf1.addActionListener(this);
lbl2=new Label ("To athroisma einai:");
add(lbl2);
tf2=new TextField(15);
add(tf2);
}
public void actionPerformed(ActionEvent e) {
s=e.getActionCommand();
num=Integer.parseInt(s);
sum=sum+num;
tf1.setText("");
s=Integer.toString(sum);
tf2.setText(s);
}
Thursday, July 16, 2009
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment