01: /*
02: * (C) Copyright IBM Corp. 1998-2004. All Rights Reserved.
03: *
04: * The program is provided "as is" without any warranty express or
05: * implied, including the warranty of non-infringement and the implied
06: * warranties of merchantibility and fitness for a particular purpose.
07: * IBM will not be liable for any damages suffered by you as a result
08: * of using the Program. In no event will IBM be liable for any
09: * special, indirect or consequential damages or lost profits even if
10: * IBM has been advised of the possibility of their occurrence. IBM
11: * will not be liable for any third party claims against you.
12: */
13: package com.ibm.richtext.textapps;
14:
15: import java.awt.event.WindowAdapter;
16: import java.awt.event.WindowEvent;
17: import java.awt.Frame;
18: import java.awt.Window;
19:
20: class AppCloser {
21:
22: static final String COPYRIGHT = "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
23: private int fCount = 0;
24:
25: private WindowAdapter fAdapter = new WindowAdapter() {
26:
27: public void windowClosing(WindowEvent e) {
28: --fCount;
29: if (fCount == 0) {
30: System.exit(0);
31: }
32: Window w = e.getWindow();
33: w.setVisible(false);
34: w.dispose();
35: }
36: };
37:
38: public void listenToFrame(Frame frame) {
39:
40: ++fCount;
41: frame.addWindowListener(fAdapter);
42: }
43: }
|