package Test_Gui;import java.awt.Frame;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;public class aa {public static void main(String[] args) {
new MyFrame().TestFrame;   
}
}
class MyFrame extends Frame{public void TestFrame(){setSize(300,300);
this.setLocation(300, 300);
this.addKeyListener(new MyKetMonet());
this.setVisible(true);
this.addWindowListener(new WindowAdapter(){
@SuppressWarnings("unused")
public void windowColsing(){
setVisible(false);
System.exit(0);
}
});
}
}
class MyKetMonet extends KeyAdapter{
public void KeyPressed(KeyEvent e){
int i = e.getKeyCode();
if(i==KeyEvent.VK_UP){
System.out.println("OK"); 
}
}
}
之后编译的时候没有错误 运行的时候报了一个
Exception in thread "main" java.lang.NoSuchMethodError: Test_Gui.MyFrame: method <init>()V not found
at Test_Gui.aa.main(aa.java:11)
错误 可是并没有给我提示啊