import java.awt.*;
import java.awt.event.*;
public class TestFrame extends Frame implements WindowListener {
public TestFrame(String s) {
super(s);
}
public void windowClosing(WindowEvent e) {
System.out.println("我退出了!");
e.getWindow().setVisible(false);
((Window)e.getComponent()).dispose();
System.exit(0);
}
public void windowActivated(WindowEvent e) {}
public void windowClosed(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowOpened(WindowEvent e) {}
public static void main(String[] args) {
TestFrame f = new TestFrame("A Test Window");
f.setSize(320, 180);
f.setVisible(true);
f.addWindowListener(f);
}
}