标题:关于运行后出现的错误
取消只看楼主
大嘴先生2
Rank: 1
等 级:新手上路
威 望:2
帖 子:815
专家分:0
注 册:2006-4-17
 问题点数:0 回复次数:0 
关于运行后出现的错误
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("窗口");
}
}
搜索更多相关主题的帖子: import JTextField awt java event 
2006-07-09 23:44



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-77462-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 2.235817 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved