package cn.sxt.game;
import javax.swing.JFrame;
public class MyGameFrame extends JFrame{
//初始化窗口
public void launchFrame() {
this.setTitle("飞机游戏作品");
this.setVisible(true);//窗口可见
this.setSize(500,500);//设置窗口大小
this.setLocation(300,300);
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
System.exit(0);
}
});
}
public static void main(String[] args) {
MyGameFrame f = new MyGameFrame();
f.launchFrame();
}
}
#############################################################
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method addWindowListener(WindowListener) in the type Window is not applicable for the arguments (new WindowAdapter(){})
WindowAdapter cannot be resolved to a type
WindowEvent cannot be resolved to a type
at cn.sxt.game.MyGameFrame.launchFrame(MyGameFrame.java:20)
at cn.sxt.game.MyGameFrame.main(MyGameFrame.java:33)