import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.util.regex.*;
class EditWindow extends JFrame implements DocumentListener
{
JTextField text1,text2,text3;
EditWindow(String s)
{
super(s);
setSize(200,250);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
text1=new JTextField();
text2=new JTextField();
text3=new JTextField();
text3.setEditable(false);
JPanel panel=new JPanel();
panel.setLayout(new GridLayout(3,1));
Container con=getContentPane();
panel.add(text1);
panel.add(text2);
panel.add(text3);
con.add(panel,BorderLayout.CENTER);
(text2.getDocument()).addDocumentListener(this);
validate();
}
public void changdeUpdate(DocumentEvent ee)
{
text3.setText(null);
double oper1,oper2;
try
{
oper1=Double.parseDouble(text1.getText());
oper2=Double.parseDouble(text2.getText());
}
catch(NumberFormatException e)
{
System.out.println("111");
}
while(text2.getText()!=null)
{
text3.setText(String.valueOf(oper1+oper2));
}
}
}
public class Tan
{
public static void main(String args[])
{
EditWindow win=new EditWindow("窗口");
}
}
//EditWindow不是抽象的,且未覆盖...是怎么回事?