本文共 497 字,大约阅读时间需要 1 分钟。
功能:添加关闭窗口的处理事件。
不允许改变窗口的大小。
知识点:引入上一个版本的内容,重写方法,匿名类的使用
public class TankClient extends Frame { public void lauchFrame(){ this.setSize(400,300); this.setTitle("TankWar"); this.setLocation(800, 600); this.setVisible(true); this.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e) { System.exit(0); } }); this.setResizable(false); } public static void main(String[] args) { TankClient tc = new TankClient(); tc.lauchFrame(); } }注意事项:重写时,注意类名不要写错!!!
转载地址:http://rorxb.baihongyu.com/