import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; /** A class used to handle WINDOW_CLOSING events */ public class WindowCloser extends WindowAdapter { /** End the program when the user closes * the window */ public void windowClosing( WindowEvent e ) { e.getWindow().dispose(); System.exit( 0 ); } }