Error while trying to run: NoSuchMethodError: main
I get this error when trying to run my code, but can't see what's wrong with it.
ERROR: Exception in thread "main" java.lang.NoSuchMethodError: main
import java.awt.*;
import java.awt.event.*;
public class Checkerboard extends Frame implements ActionListener {
Button btnGo = new Button ("Go");
Button btnClear = new Button("Clear");
Label lblStart = new Label("Start");
Label lblStop = new Label("Stop");
Label lblStep = new Label("Step");
TextField txtStart = new TextField(10);
TextField txtStop = new TextField(10);
TextField txtStep = new TextField(10);
Panel pnlCenter = new Panel();
Panel pnlSouth = new Panel();
Panel pnlInput = new Panel();
开发者_Go百科 Panel pnlButton = new Panel();
GridLayout gridColors = new GridLayout(4,4);
GridLayout gridInput = new GridLayout(2,3);
TextField txtArray[];
public Checkerboard () {
txtArray = new TextField[16];
addWindowListener(new WindowAdapter() {
public void windowClosing (WindowEvent e) {
System.exit(0);
}
});
btnGo.addActionListener(this);
btnClear.addActionListener(this);
setLayout(new BorderLayout());
pnlCenter.setLayout(gridColors);
for(int i = 0; i < 16; i++) {
txtArray[i] = new TextField(Integer.toString(i));
txtArray[i].setEditable(false);
txtArray[i].setBackground(Color.white);
pnlCenter.add(txtArray[i]);
}
pnlInput.setLayout(gridInput);
pnlInput.add(txtStart);
pnlInput.add(txtStop);
pnlInput.add(txtStep);
pnlInput.add(lblStart);
pnlInput.add(lblStop);
pnlInput.add(lblStep);
pnlButton.add(btnGo);
pnlButton.add(btnClear);
add("Center", pnlCenter);
}
public void actionPerformed(ActionEvent e){
}
}
ERROR: Exception in thread "main" java.lang.NoSuchMethodError: main
I don't see a main
method anywhere in this class. Do you?
The JVM looks for a main
method from which the execution of your program begins. e.g.
public static void main (String[] args) {
new CheckerBoard();
}
精彩评论