01: // ClosableDialog.java
02: // $Id: ClosableDialog.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.Frame;
09: import java.awt.event.WindowAdapter;
10: import java.awt.event.WindowEvent;
11:
12: import javax.swing.JDialog;
13:
14: /**
15: * A Dialog that handles windowClosing event.
16: * @version $Revision: 1.4 $
17: * @author Benoît Mahé (bmahe@w3.org)
18: */
19: abstract public class ClosableDialog extends JDialog {
20:
21: /**
22: * Our internal WindowAdapter
23: */
24: WindowAdapter wl = new WindowAdapter() {
25: public void windowClosing(WindowEvent e) {
26: if (e.getWindow() == ClosableDialog.this )
27: close();
28: }
29: };
30:
31: /**
32: * The dialog is about to be closed
33: */
34: protected abstract void close();
35:
36: /**
37: * Constructor
38: */
39: public ClosableDialog() {
40: super ();
41: build();
42: }
43:
44: /**
45: * Constructor
46: * @param frame the frame from which the dialog is displayed
47: * @param title the String to display in the dialog's title bar
48: * @param modal true for a modal dialog, false for one that allows
49: * others windows to be active at the same time
50: */
51: public ClosableDialog(Frame frame, String title, boolean modal) {
52: super (frame, title, modal);
53: build();
54: }
55:
56: private void build() {
57: addWindowListener(wl);
58: }
59:
60: }
|