import java.awt.event.* ; import javax.swing.* ; class TerminationListener implements WindowListener { public void windowActivated(WindowEvent e) {} public void windowClosed(WindowEvent e) {} public void windowClosing(WindowEvent e) { System.exit(0) ; } public void windowDeactivated(WindowEvent e) {} public void windowDeiconified(WindowEvent e) {} public void windowIconified(WindowEvent e) {} public void windowOpened(WindowEvent e) {} } class SimpleFrame extends JFrame { public SimpleFrame() { setTitle("SimpleFrame") ; setSize(450, 300) ; addWindowListener(new TerminationListener()) ; } } public class TerminationTest { public static void main(String [] args) { JFrame frame = new SimpleFrame() ; frame.show() ; } }