Debian Codegraph @

demos/src/main/java/com/ibm/icu/dev/demo/translit/DemoApplet.java

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