01: package net.matuschek.swing;
02:
03: import javax.swing.JFrame;
04:
05: /*********************************************
06: Copyright (c) 2001 by Daniel Matuschek
07: *********************************************/
08:
09: /**
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 {
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 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() {
41: public void windowClosing(java.awt.event.WindowEvent evt) {
42: exitForm();
43: }
44: });
45: }
46:
47: /**
48: * Overwrite this method if you want to do something special on
49: * a windowClosing event.
50: * By default this will set the window invisible.
51: */
52: protected void exitForm() {
53: setVisible(false);
54: }
55:
56: } // JHideFrame
|