日期:2014-05-20 浏览次数:20696 次
package com.yixq.GUI; import java.awt.Color; import java.awt.Frame; import java.awt.event.*; public class WindowEvent { public static void main(String[] args) { new MyFrame5("abce"); } } class MyFrame5 extends Frame { MyFrame5(String s) { super(s); setLayout(null); setBounds(300, 300, 300, 200); setBackground(Color.cyan); setVisible(true); this.addWindowListener(new Monitor5()); } class Monitor5 extends WindowAdapter { @Override public void windowClosing(java.awt.event.WindowEvent e) { setVisible(false); System.exit(-1); } } }