01: // ClosableFrame.java
02: // $Id: ClosableFrame.java,v 1.4 2000/08/16 21:37:31 ylafon Exp $
03: // (c) COPYRIGHT MIT and INRIA, 1998.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.jigadmin.widgets;
07:
08: import java.awt.event.WindowAdapter;
09: import java.awt.event.WindowEvent;
10:
11: import javax.swing.JFrame;
12:
13: /**
14: * A Frame that handles windowClosing event.
15: * @version $Revision: 1.4 $
16: * @author Benoît Mahé (bmahe@w3.org)
17: */
18: abstract public class ClosableFrame extends JFrame {
19:
20: /**
21: * Our internal WindowAdapter
22: */
23: WindowAdapter wl = new WindowAdapter() {
24: public void windowClosing(WindowEvent e) {
25: if (e.getWindow() == ClosableFrame.this )
26: close();
27: }
28: };
29:
30: /**
31: * The dialog is about to be closed
32: */
33: protected abstract void close();
34:
35: /**
36: * Constructor
37: */
38: public ClosableFrame() {
39: super ();
40: build();
41: }
42:
43: /**
44: * Constructor
45: * @param title The frame title.
46: */
47: public ClosableFrame(String title) {
48: super (title);
49: build();
50: }
51:
52: private void build() {
53: addWindowListener(wl);
54: }
55:
56: }
|