import java.awt.*; import java.awt.event.*; /** * Makes use of an "anonymous" inner class to listen to the WindowClosing event. */ public class SimpleAnonymousGUI { private Frame _frame; // The frame for the GUI. public SimpleAnonymousGUI() { _frame = new Frame("Simple GUI"); /** * Standard way to free system's resources for Window class when closing. */ _frame.addWindowListener ( new WindowAdapter() { public void windowClosing(WindowEvent e) { _frame.dispose (); //frees system's resources. System.exit(0); } } ); _frame.setSize (240, 300); _frame.setVisible (true); } /*** * Entry point into the program * @param args The parameters for the entry. They are not used here. */ public static void main(String[] args) { new SimpleAnonymousGUI(); } }