![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e568. Determining When a Frame or Window Is Opened or Closed// Create the frame Frame frame = new Frame(); // Create a listener for window events WindowListener listener = new WindowAdapter() { // This method is called after a window has been opened public void windowOpened(WindowEvent evt) { Frame frame = (Frame)evt.getSource(); } // This method is called when the user clicks the close button public void windowClosing(WindowEvent evt) { Frame frame = (Frame)evt.getSource(); // By default, nothing happens when the user clicks the close button. // To close the frame, see e565 Hiding a Frame When Its Close Button Is Clicked } // This method is called after a window is closed public void windowClosed(WindowEvent evt) { Frame frame = (Frame)evt.getSource(); } }; // Register the listener with the frame frame.addWindowListener(listener);
e560. Setting the Icon for a Frame e561. Making a Frame Non-Resizable e562. Removing the Title Bar of a Frame e563. Setting the Bounds for a Maximized Frame e564. Iconifying and Maximizing a Frame e565. Hiding a Frame When Its Close Button Is Clicked e566. Exiting an Application When a Frame Is Closed e567. Getting All Created Frames in an Application e569. Determining When a Frame or Window Is Iconized or Maximized
© 2002 Addison-Wesley. |