![]() |
The Java Developers Almanac 1.4 |
|
e565. Hiding a Frame When Its Close Button Is ClickedBy default, when the close button on a frame is clicked, nothing happens. This example shows how to make the action hide the frame. One reason for hiding rather than disposing a frame would be to reuse the frame later. // Create a frame
Frame frame = new Frame();
// Add a listener for the close event
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
Frame frame = (Frame)evt.getSource();
// Hide the frame
frame.setVisible(false);
// If the frame is no longer needed, call dispose
frame.dispose();
}
});
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 e566. Exiting an Application When a Frame Is Closed e567. Getting All Created Frames in an Application e568. Determining When a Frame or Window Is Opened or Closed e569. Determining When a Frame or Window Is Iconized or Maximized
© 2002 Addison-Wesley. |