ActionEvent e;
public void start(){
do{
but1.addActionListener(new ButtonHandler());
but2.addActionListener(new ButtonHandler());
if(e.getActionCommand() == "验证风速值"){
String Line1 = text1.getText();。。中的
if(e.getActionCommand() == "验证风速值"){
e只是在上面申明了ActionEvent e;并没有初始化,所以在这里使用的时候就会出现空指针错误,你想点击按钮"验证风速值"时执行,但是AppletPanel已经自动执行了你的start()语句。
public void start(){
do{
but1.addActionListener(new ButtonHandler());
but2.addActionListener(new ButtonHandler());
if(e.getActionCommand() == "验证风速值"){
String Line1 = text1.getText();。。中的
if(e.getActionCommand() == "验证风速值"){
e只是在上面申明了ActionEvent e;并没有初始化,所以在这里使用的时候就会出现空指针错误,你想点击按钮"验证风速值"时执行,但是AppletPanel已经自动执行了你的start()语句。
start(e);
} } //ActionEvent e; public void start(ActionEvent e) {
add(but4);
setSize(100, 200);
setVisible(true);
Component[] cs=this.getComponents();
for(int i=0;i<cs.length;i++){
if(cs[i] instanceof Button){
((Button)cs[i]).addActionListener(new ButtonHandler());
}
}
可以知道你的联系方式吗?