import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.io.*;
/*
*/
public class ca extends Applet
{
TextField tx0=new TextField(10);
TextField tx1=new TextField(10);
TextField tx2=new TextField(10);
Button B0=new Button("Add");
String str;
double x,y,z;
public void start()
{
add(new Label("Enter a text:\r\n"));
add(tx0);
add(new Label("Enter a text:\r\n"));
add(tx1);
B0.addActionListener(new CAL());
add(B0);
add(tx2);
//tx2.setVisible(false);
}
class CAL implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
str=tx0.getText();
x=Double.parseDouble(str);
str=tx1.getText();
y=Double.parseDouble(str);
z=x+y;
str=String.valueOf(z);
tx2.setText(str);
}
}
public void actionPerformed(ActionEvent ae)
{
repaint();
}
}
OutPut:
|
0 comments:
Post a Comment