01: // ClosableFrame.java
02: // $Id: ClosableFrame.java,v 1.3 2000/08/16 21:37:56 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.tools.widgets;
07:
08: import java.awt.Color;
09: import java.awt.Component;
10: import java.awt.Frame;
11: import java.awt.Window;
12:
13: import java.awt.event.WindowAdapter;
14: import java.awt.event.WindowEvent;
15:
16: /**
17: * @version $Revision: 1.3 $
18: * @author Benoît Mahé (bmahe@w3.org)
19: */
20: abstract public class ClosableFrame extends Frame {
21:
22: class WindowCloser extends WindowAdapter {
23:
24: ClosableFrame frame = null;
25:
26: public void windowClosing(WindowEvent e) {
27: if (e.getWindow() == frame)
28: frame.close();
29: }
30:
31: WindowCloser(ClosableFrame frame) {
32: this .frame = frame;
33: }
34: }
35:
36: protected abstract void close();
37:
38: public ClosableFrame() {
39: super ();
40: build();
41: }
42:
43: public ClosableFrame(String title) {
44: super (title);
45: build();
46: }
47:
48: private void build() {
49: addWindowListener(new WindowCloser(this));
50: setBackground(Color.lightGray);
51: }
52:
53: }
|