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