public class Demo01 extends Frame{ public Demo01(){ super("Demo01");//标题 this.setSize(450, 500);//窗口的大小 this.setLocation(100,100);//窗口距离屏幕的距离 this.setVisible(true); this.addWindowListener(new WindowAdapter() {//点击关闭按钮可以关闭程序 @Override public void windowClosing(WindowEvent e) { System.exit(0); } }); } public static void main(String[] args) { new Demo01(); } }