关于运行后出现的错误
import javax.swing.*;import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
class EditWindow extends JFrame implements ActionListener
{
JTextField text1,text2,text3;
JPanel jpanel;
EditWindow(String s)
{
super(s);
setSize(300,250);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
text1=new JTextField(20);
text2=new JTextField(20);
text3=new JTextField(20);
text3.setEditable(false);
jpanel=new JPanel();
Container con=getContentPane();
jpanel.add(text1);
jpanel.add(text2);
jpanel.add(text3);
con.add(jpanel,BorderLayout.CENTER);
text1.addActionListener(this);
text2.addActionListener(this);
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
double oper1=0,oper2=0;
try
{
oper1=Double.parseDouble(text1.getText());
oper2=Double.parseDouble(text2.getText());
text3.setText("="+String.valueOf(oper1+oper2));
}
catch(NumberFormatException ee)
{
JOptionPane.showMessageDialog( this,"Invalid Operand", "Invalid Number Format",
JOptionPane.ERROR_MESSAGE );//每次输入第一个数字时候,总是异常?为什么??
return;
}
}
}
public class Tan1
{
public static void main(String args[])
{
EditWindow win=new EditWindow("窗口");
}
}