import java.awt.*; import java.awt.event.*; // This appears in Core Web Programming from // Prentice Hall Publishers, and may be freely used // or adapted. 1997 Marty Hall, hall@apl.jhu.edu. /** A Frame that you can actually quit. Used as * the starting point for most Java 1.1 graphical * applications. QuittableFrame is the Java 1.0 version. * @see QuittableFrame */ public class CloseableFrame extends Frame { public CloseableFrame(String title) { super(title); enableEvents(AWTEvent.WINDOW_EVENT_MASK); } /** Since we are doing something permanent, we need * to call super.processWindowEvent first. */ public void processWindowEvent(WindowEvent event) { super.processWindowEvent(event); // Handle listeners if (event.getID() == WindowEvent.WINDOW_CLOSING) System.exit(0); } }