import java.awt.*;
import java.awt.event.*;
import java.text.*;
import javax.swing.*;
class JaFa1 extends JFrame implements DocumentListener
{
JTextField T1,T2,T3;
JaFa1(String s)
{
super(s);
T1=new JTextField(10);
T2=new JTextField(10);
T3=new JTextField(12);
T1.addDocumentListener(this);
T2.addDocumentListener(this);
T3.setEditable(false);
Container con=getContentPane();
con.setLayout(new FlowLayout());
con.add(T1);
con.add(T2);
con.add(T3);
setBounds(100,100,150,150);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void changedUpdate(DocumentEvent e)
{
if(e.getSource()==T1)
{
T3.setTextField(Double.parseDouble(T1.getText())+Double.parseDouble(T2.getText()));
}
else if(e.getSource()==T2)
{
T3.setTextField(Double.parseDouble(T1.getText())+Double.parseDouble(T2.getText()));
}
else
{
T3.setTextField(Double.parseDouble(T1.getText())+Double.parseDouble(T2.getText()));
}
public void removeUpdate(DocumentEvent e)
{
ChangedUpdate(e);
}
public void insertUpdate(DocumentEvent e)
{
ChangedUpdate(e);
}
}
}