]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_2_1-src/src/com/ibm/richtext/textapps/AppCloser.java
go
[Dictionary.git] / jars / icu4j-4_2_1-src / src / com / ibm / richtext / textapps / AppCloser.java
1 /*\r
2  * (C) Copyright IBM Corp. 1998-2004.  All Rights Reserved.\r
3  *\r
4  * The program is provided "as is" without any warranty express or\r
5  * implied, including the warranty of non-infringement and the implied\r
6  * warranties of merchantibility and fitness for a particular purpose.\r
7  * IBM will not be liable for any damages suffered by you as a result\r
8  * of using the Program. In no event will IBM be liable for any\r
9  * special, indirect or consequential damages or lost profits even if\r
10  * IBM has been advised of the possibility of their occurrence. IBM\r
11  * will not be liable for any third party claims against you.\r
12  */\r
13 package com.ibm.richtext.textapps;\r
14 \r
15 import java.awt.event.WindowAdapter;\r
16 import java.awt.event.WindowEvent;\r
17 import java.awt.Frame;\r
18 import java.awt.Window;\r
19 \r
20 class AppCloser {\r
21 \r
22     static final String COPYRIGHT =\r
23                 "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";\r
24     private int fCount = 0;\r
25 \r
26     private WindowAdapter fAdapter = new WindowAdapter() {\r
27 \r
28         public void windowClosing(WindowEvent e) {\r
29             --fCount;\r
30             if (fCount == 0) {\r
31                 System.exit(0);\r
32             }\r
33             Window w = e.getWindow();\r
34             w.setVisible(false);\r
35             w.dispose();\r
36         }\r
37     };\r
38 \r
39     public void listenToFrame(Frame frame) {\r
40 \r
41         ++fCount;\r
42         frame.addWindowListener(fAdapter);\r
43     }\r
44 }\r