KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > matuschek > swing > JHideFrame


1 package net.matuschek.swing;
2
3 import javax.swing.JFrame JavaDoc;
4 /*********************************************
5     Copyright (c) 2001 by Daniel Matuschek
6  *********************************************/

7
8
9 /**
10  * This simple Frame class extends JFrame with a default event
11  * handler for "close" events that does setInvisible()
12  *
13  * @author Daniel Matuschek
14  * @version $Revision: 1.4 $
15  */

16 public class JHideFrame extends JFrame JavaDoc {
17
18     private static final long serialVersionUID = 1L;
19
20     /**
21      * @see JFrame#JFrame()
22      */

23     public JHideFrame() {
24         super();
25         installCloseHandler();
26     }
27
28     /**
29      * @see JFrame#JFrame(String)
30      */

31     public JHideFrame(String JavaDoc title) {
32         super(title);
33         installCloseHandler();
34     }
35
36     /**
37      * installs a event handler for closing the frame
38      */

39     protected void installCloseHandler() {
40         addWindowListener(new java.awt.event.WindowAdapter JavaDoc() {
41             public void windowClosing(java.awt.event.WindowEvent JavaDoc evt) {
42                 exitForm();
43             }
44         }
45         );
46     }
47
48     /**
49      * Overwrite this method if you want to do something special on
50      * a windowClosing event.
51      * By default this will set the window invisible.
52      */

53     protected void exitForm()
54     {
55         setVisible(false);
56     }
57
58 } // JHideFrame
59
Popular Tags