2 *******************************************************************************
3 * Copyright (C) 1996-2010, International Business Machines Corporation and *
4 * others. All Rights Reserved. *
5 *******************************************************************************
7 package com.ibm.icu.dev.demo.impl;
8 import java.applet.Applet;
9 import java.applet.AppletContext;
10 import java.applet.AppletStub;
11 import java.applet.AudioClip;
12 import java.awt.Frame;
13 import java.awt.Image;
14 import java.awt.event.WindowAdapter;
15 import java.awt.event.WindowEvent;
16 import java.io.IOException;
17 import java.io.InputStream;
19 import java.util.Enumeration;
20 import java.util.Iterator;
23 * <p>A Frame that runs an Applet within itself, making it possible
24 * for an applet to run as an application. Usage:
27 * public class MyApplet extends Applet {
28 * public static void main(String args[]) {
29 * MyApplet applet = new MyApplet();
30 * new AppletFrame("My Applet Running As An App", applet, 640, 480);
38 public class AppletFrame extends Frame implements AppletStub, AppletContext {
43 private static final long serialVersionUID = 818828281190757725L;
47 * Construct a Frame running the given Applet with the default size
49 * When the Frame is closed, the applet's stop() method is called,
50 * the Frame is dispose()d of, and System.exit(0) is called.
52 * @param name the Frame title
53 * @param applet the applet to be run
55 public AppletFrame(String name, Applet applet) {
56 this(name, applet, 640, 480);
60 * Construct a Frame running the given Applet with the given size.
61 * When the Frame is closed, the applet's stop() method is called,
62 * the Frame is dispose()d of, and System.exit(0) is called.
64 * @param name the Frame title
65 * @param applet the applet to be run
66 * @param width width of the Frame
67 * @param height height of the Frame
69 public AppletFrame(String name, Applet applet, int width, int height) {
74 setSize(width, height);
75 add("Center", applet);
77 addWindowListener(new WindowAdapter() {
78 public void windowClosing(WindowEvent e) {
79 AppletFrame.this.applet.stop();
90 public void appletResize(int width, int height) {
91 setSize(width, height);
94 public AppletContext getAppletContext() {
98 public URL getCodeBase() {
102 public URL getDocumentBase() {
106 public String getParameter(String name) {
110 public boolean isActive() {
116 public Applet getApplet(String name) {
120 public Enumeration getApplets() {
124 public AudioClip getAudioClip(URL url) {
128 public Image getImage(URL url) {
132 public void showDocument(URL url) {}
133 public void showDocument(URL url, String target) {}
135 public void showStatus(String status) {
136 System.out.println(status);
139 public void setStream(String key, InputStream stream) throws IOException {
142 public InputStream getStream(String key) {
146 public Iterator getStreamKeys() {