Pages

Subscribe:

Blogger templates

Sample Text

Total Pageviews

Followers

About Us

My Photo
MY Name is Vicky. I am student in Univercity.Programming and webdesigning but i don't like Maths.Someone should kill the teacher .Besides i like writing stories ,and sciencefiction scripts .Soon i will have my book and a movie !!Like so much cooking & travelling all over the world an learn about other cultures! An artistic kid and art is my breath !

Thursday, July 16, 2009

2 TEXT BOXES (ADDING NUMBERS)-APPLET

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);

}

0 comments:

Post a Comment