各位高手,下列代碼錯在那裡呢?
package javaapplication11;
import java.awt.*;
import java.awt.event.*;public class JavaApplication11 extends Frame implements ActionListener{
public JavaApplication11()
{
setTitle("My Calculator");
setSize(350,350);
setVisible(true);
setLayout(new GridLayout(3,3));
Button b1;
Button b2;
Button b3;
Button b4;
Button b5;
Button b6;
Button b7;
Button b8;
Button b9;
b1=new Button("1");
b2=new Button("2");
b3=new Button("3");
b4=new Button("4");
b5=new Button("5");
b6=new Button("6");
b7=new Button("7");
b8=new Button("8");
b9=new Button("9");
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
b7.addActionListener(this);
b8.addActionListener(this);
b9.addActionListener(this);
}public void actionPerform(ActionEvent e){
} public static void main(String[] args) {
new JavaApplication11();
}
}
package javaapplication11;
import java.awt.*;
import java.awt.event.*;public class JavaApplication11 extends Frame implements ActionListener{
public JavaApplication11()
{
setTitle("My Calculator");
setSize(350,350);
setVisible(true);
setLayout(new GridLayout(3,3));
Button b1;
Button b2;
Button b3;
Button b4;
Button b5;
Button b6;
Button b7;
Button b8;
Button b9;
b1=new Button("1");
b2=new Button("2");
b3=new Button("3");
b4=new Button("4");
b5=new Button("5");
b6=new Button("6");
b7=new Button("7");
b8=new Button("8");
b9=new Button("9");
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
b7.addActionListener(this);
b8.addActionListener(this);
b9.addActionListener(this);
}public void actionPerform(ActionEvent e){
} public static void main(String[] args) {
new JavaApplication11();
}
}
原來我把 actionPerformed(ActionEvent e){}打成actionPerform(ActionEvent e){}