import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
public class JiaFa extends JFrame implements ActionListener
{
private JTextField jt1=new JTextField(5);
private JTextField jt2=new JTextField(5);
private JTextField result=new JTextField(5);
private JButton btn=new JButton("=");
JLabel label=new JLabel("+");
public void init(){
Container cp=getContentPane();
cp.setLayout(new FlowLayout(FlowLayout.LEFT));
cp.add(jt1);
cp.add(label);
cp.add(jt2);
cp.add(btn);
cp.add(result);
setSize(300,80);
setVisible(true);
btn.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==btn)
{
int a=Integer.parseInt(jt1.getText());
int b=Integer.parseInt(jt2.getText());
int c=a+b;
String str=String.valueOf(c);
result.setText(str);
}
}
public static void main(String args[])
{
JFrame cp=new JiaFa();
cp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}