]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_4_2-src/demos/src/com/ibm/icu/dev/demo/translit/DemoApplet.java
go
[Dictionary.git] / jars / icu4j-4_4_2-src / demos / src / com / ibm / icu / dev / demo / translit / DemoApplet.java
1 /*\r
2  *******************************************************************************\r
3  * Copyright (C) 1996-2010, International Business Machines Corporation and    *\r
4  * others. All Rights Reserved.                                                *\r
5  *******************************************************************************\r
6  */\r
7 package com.ibm.icu.dev.demo.translit;\r
8 import java.applet.Applet;\r
9 import java.awt.Button;\r
10 import java.awt.Dimension;\r
11 import java.awt.event.ActionEvent;\r
12 import java.awt.event.ActionListener;\r
13 import java.awt.event.WindowAdapter;\r
14 import java.awt.event.WindowEvent;\r
15 \r
16 import com.ibm.icu.dev.demo.impl.AppletFrame;\r
17 \r
18 /**\r
19  * A simple Applet that shows a button.  When pressed, the button\r
20  * shows the DemoAppletFrame.  This Applet is meant to be embedded\r
21  * in a web page.\r
22  *\r
23  * <p>Copyright (c) IBM Corporation 1999.  All rights reserved.\r
24  *\r
25  * @author Alan Liu\r
26  */\r
27 public class DemoApplet extends Applet {\r
28 \r
29     /**\r
30      * For serialization\r
31      */\r
32     private static final long serialVersionUID = 8214879807740061678L;\r
33     Demo frame = null;\r
34     \r
35     public static void main(String args[]) {\r
36         final DemoApplet applet = new DemoApplet();\r
37         new AppletFrame("Transliteration Demo", applet, 640, 480);\r
38     }\r
39 \r
40     public void init() {\r
41 \r
42         Button button = new Button("Transliteration Demo");\r
43         button.addActionListener(new ActionListener() {\r
44             public void actionPerformed(ActionEvent e) {\r
45                 if (frame == null) {\r
46                     frame = new Demo(600, 200);\r
47                     frame.addWindowListener(new WindowAdapter() {\r
48                         public void windowClosing(WindowEvent we) {\r
49                             frame = null;\r
50                         }\r
51                     });\r
52                 }\r
53                 frame.setVisible(true);\r
54                 frame.toFront();\r
55             }\r
56         });\r
57 \r
58         add(button);\r
59 \r
60         Dimension size = button.getPreferredSize();\r
61         size.width += 10;\r
62         size.height += 10;\r
63 \r
64         resize(size);\r
65     }\r
66     \r
67     public void stop() {\r
68         if (frame != null) {\r
69             frame.dispose();\r
70         }\r
71         frame = null;\r
72     }\r
73 }\r