package dohoajava;
import java.awt.*;
import java.awt.event.*;
public class dasdsaf extends Frame implements ActionListener{
Label nh1,nh2,nhkq;
TextField txt1,txt2;
Button cong,thoat;
public dasdsaf(){
super("TINHTOAN");
this.setLayout(new GridLayout(5,5));//FlowLayout()
nh1=new Label("Ban hay nhap x");
//nh1.setBounds(200,200,50,60);
this.add(nh1);
txt1=new TextField();
this.add(txt1);
nh2=new Label("Ban hay nhap x");
//nh1.setBounds(200,200,50,60);
this.add(nh2);
txt2=new TextField();
this.add(txt2);
nhkq=new Label("");
//nh1.setBounds(200,200,50,60);
this.add(nhkq);
cong=new Button("cong");
cong.addActionListener(this);
this.add(cong);
thoat=new Button("thoat");
thoat.addActionListener(this);
this.add(thoat);
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent f){
float x=Float.parseFloat(txt1.getText());
float y=Float.parseFloat(txt2.getText());
float kq=0;
if(f.getSource()==cong)
kq=x+y;
if(f.getSource()==thoat)
System.exit(0);
nhkq.setText(""+String.valueOf(kq));
}
public static void main(String[]args){
dasdsaf o=new dasdsaf();
o.setSize(500,500);
o.setVisible(true);
}
}