jdk/src/share/classes/java/applet/Applet.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 4261 126dc6fe0d7b
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1995-2006 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package java.applet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.image.ColorModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.net.URL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.net.MalformedURLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.Hashtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.Locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.accessibility.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * An applet is a small program that is intended not to be run on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * its own, but rather to be embedded inside another application.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * The <code>Applet</code> class must be the superclass of any
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * applet that is to be embedded in a Web page or viewed by the Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * Applet Viewer. The <code>Applet</code> class provides a standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * interface between applets and their environment.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * @author      Arthur van Hoff
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * @author      Chris Warth
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * @since       JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
public class Applet extends Panel {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * Constructs a new Applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * Note: Many methods in <code>java.applet.Applet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * may be invoked by the applet only after the applet is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * fully constructed; applet should avoid calling methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * in <code>java.applet.Applet</code> in the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    public Applet() throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        if (GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
            throw new HeadlessException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * Applets can be serialized but the following conventions MUST be followed:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * Before Serialization:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * An applet must be in STOPPED state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * After Deserialization:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * The applet will be restored in STOPPED state (and most clients will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * likely move it into RUNNING state).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * The stub field will be restored by the reader.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    transient private AppletStub stub;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    /* version ID for serialized form. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    private static final long serialVersionUID = -5836846270535785031L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * Read an applet from an object input stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * @exception HeadlessException if
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * <code>GraphicsEnvironment.isHeadless()</code> returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    private void readObject(ObjectInputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        throws ClassNotFoundException, IOException, HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        if (GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            throw new HeadlessException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        s.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * Sets this applet's stub. This is done automatically by the system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * <p>If there is a security manager, its <code> checkPermission </code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * method is called with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * <code>AWTPermission("setAppletStub")</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * permission if a stub has already been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @param   stub   the new stub.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * @exception SecurityException if the caller cannot set the stub
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    public final void setStub(AppletStub stub) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        if (this.stub != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            SecurityManager s = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            if (s != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                s.checkPermission(new AWTPermission("setAppletStub"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        this.stub = (AppletStub)stub;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * Determines if this applet is active. An applet is marked active
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * just before its <code>start</code> method is called. It becomes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * inactive just before its <code>stop</code> method is called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @return  <code>true</code> if the applet is active;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     *          <code>false</code> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @see     java.applet.Applet#start()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @see     java.applet.Applet#stop()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    public boolean isActive() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        if (stub != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            return stub.isActive();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        } else {        // If stub field not filled in, applet never active
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * Gets the URL of the document in which this applet is embedded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * For example, suppose an applet is contained
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * within the document:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     *    http://java.sun.com/products/jdk/1.2/index.html
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * The document base is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *    http://java.sun.com/products/jdk/1.2/index.html
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @return  the {@link java.net.URL} of the document that contains this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     *          applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * @see     java.applet.Applet#getCodeBase()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    public URL getDocumentBase() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        return stub.getDocumentBase();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * Gets the base URL. This is the URL of the directory which contains this applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * @return  the base {@link java.net.URL} of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     *          the directory which contains this applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * @see     java.applet.Applet#getDocumentBase()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    public URL getCodeBase() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        return stub.getCodeBase();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * Returns the value of the named parameter in the HTML tag. For
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * example, if this applet is specified as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * &lt;applet code="Clock" width=50 height=50&gt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * &lt;param name=Color value="blue"&gt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * &lt;/applet&gt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * then a call to <code>getParameter("Color")</code> returns the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * value <code>"blue"</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * The <code>name</code> argument is case insensitive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * @param   name   a parameter name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * @return  the value of the named parameter,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     *          or <code>null</code> if not set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     public String getParameter(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
         return stub.getParameter(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * Determines this applet's context, which allows the applet to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * query and affect the environment in which it runs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * This environment of an applet represents the document that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * contains the applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * @return  the applet's context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    public AppletContext getAppletContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        return stub.getAppletContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * Requests that this applet be resized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * @param   width    the new requested width for the applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * @param   height   the new requested height for the applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    public void resize(int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        Dimension d = size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        if ((d.width != width) || (d.height != height)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            super.resize(width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            if (stub != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                stub.appletResize(width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * Requests that this applet be resized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * @param   d   an object giving the new width and height.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    public void resize(Dimension d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        resize(d.width, d.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * Requests that the argument string be displayed in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * "status window". Many browsers and applet viewers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * provide such a window, where the application can inform users of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * its current state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * @param   msg   a string to display in the status window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    public void showStatus(String msg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        getAppletContext().showStatus(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * Returns an <code>Image</code> object that can then be painted on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * the screen. The <code>url</code> that is passed as an argument
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * must specify an absolute URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * This method always returns immediately, whether or not the image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * exists. When this applet attempts to draw the image on the screen,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * the data will be loaded. The graphics primitives that draw the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * image will incrementally paint on the screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * @param   url   an absolute URL giving the location of the image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * @return  the image at the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * @see     java.awt.Image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    public Image getImage(URL url) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        return getAppletContext().getImage(url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * Returns an <code>Image</code> object that can then be painted on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * the screen. The <code>url</code> argument must specify an absolute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * URL. The <code>name</code> argument is a specifier that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * relative to the <code>url</code> argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * This method always returns immediately, whether or not the image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * exists. When this applet attempts to draw the image on the screen,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * the data will be loaded. The graphics primitives that draw the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * image will incrementally paint on the screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * @param   url    an absolute URL giving the base location of the image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * @param   name   the location of the image, relative to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     *                 <code>url</code> argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * @return  the image at the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * @see     java.awt.Image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    public Image getImage(URL url, String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            return getImage(new URL(url, name));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        } catch (MalformedURLException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * Get an audio clip from the given URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * @param url points to the audio clip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * @return the audio clip at the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * @since       1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    public final static AudioClip newAudioClip(URL url) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        return new sun.applet.AppletAudioClip(url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * Returns the <code>AudioClip</code> object specified by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * <code>URL</code> argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * This method always returns immediately, whether or not the audio
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * clip exists. When this applet attempts to play the audio clip, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * data will be loaded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * @param   url  an absolute URL giving the location of the audio clip.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * @return  the audio clip at the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * @see     java.applet.AudioClip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    public AudioClip getAudioClip(URL url) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        return getAppletContext().getAudioClip(url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * Returns the <code>AudioClip</code> object specified by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * <code>URL</code> and <code>name</code> arguments.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * This method always returns immediately, whether or not the audio
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * clip exists. When this applet attempts to play the audio clip, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * data will be loaded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * @param   url    an absolute URL giving the base location of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     *                 audio clip.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * @param   name   the location of the audio clip, relative to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     *                 <code>url</code> argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * @return  the audio clip at the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * @see     java.applet.AudioClip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    public AudioClip getAudioClip(URL url, String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
            return getAudioClip(new URL(url, name));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        } catch (MalformedURLException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * Returns information about this applet. An applet should override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * this method to return a <code>String</code> containing information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * about the author, version, and copyright of the applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * The implementation of this method provided by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * <code>Applet</code> class returns <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * @return  a string containing information about the author, version, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     *          copyright of the applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    public String getAppletInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * Gets the locale of the applet. It allows the applet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * to maintain its own locale separated from the locale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * of the browser or appletviewer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * @return  the locale of the applet; if no locale has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     *          been set, the default locale is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * @since   JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    public Locale getLocale() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
      Locale locale = super.getLocale();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
      if (locale == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        return Locale.getDefault();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
      return locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * Returns information about the parameters that are understood by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * this applet. An applet should override this method to return an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * array of <code>Strings</code> describing these parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * Each element of the array should be a set of three
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * <code>Strings</code> containing the name, the type, and a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * description. For example:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * <p><blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * String pinfo[][] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     *   {"fps",    "1-10",    "frames per second"},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     *   {"repeat", "boolean", "repeat image loop"},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     *   {"imgs",   "url",     "images directory"}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * The implementation of this method provided by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * <code>Applet</code> class returns <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * @return  an array describing the parameters this applet looks for.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    public String[][] getParameterInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * Plays the audio clip at the specified absolute URL. Nothing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * happens if the audio clip cannot be found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * @param   url   an absolute URL giving the location of the audio clip.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    public void play(URL url) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        AudioClip clip = getAudioClip(url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        if (clip != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            clip.play();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * Plays the audio clip given the URL and a specifier that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * relative to it. Nothing happens if the audio clip cannot be found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * @param   url    an absolute URL giving the base location of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     *                 audio clip.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * @param   name   the location of the audio clip, relative to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     *                 <code>url</code> argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    public void play(URL url, String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        AudioClip clip = getAudioClip(url, name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        if (clip != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
            clip.play();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * Called by the browser or applet viewer to inform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * this applet that it has been loaded into the system. It is always
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * called before the first time that the <code>start</code> method is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * A subclass of <code>Applet</code> should override this method if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * it has initialization to perform. For example, an applet with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * threads would use the <code>init</code> method to create the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * threads and the <code>destroy</code> method to kill them.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * The implementation of this method provided by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * <code>Applet</code> class does nothing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * @see     java.applet.Applet#destroy()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * @see     java.applet.Applet#start()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * @see     java.applet.Applet#stop()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    public void init() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * Called by the browser or applet viewer to inform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * this applet that it should start its execution. It is called after
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * the <code>init</code> method and each time the applet is revisited
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * in a Web page.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * A subclass of <code>Applet</code> should override this method if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * it has any operation that it wants to perform each time the Web
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * page containing it is visited. For example, an applet with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * animation might want to use the <code>start</code> method to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * resume animation, and the <code>stop</code> method to suspend the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * animation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * Note: some methods, such as <code>getLocationOnScreen</code>, can only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * provide meaningful results if the applet is showing.  Because
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * <code>isShowing</code> returns <code>false</code> when the applet's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * <code>start</code> is first called, methods requiring
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * <code>isShowing</code> to return <code>true</code> should be called from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * a <code>ComponentListener</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * The implementation of this method provided by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * <code>Applet</code> class does nothing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * @see     java.applet.Applet#destroy()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * @see     java.applet.Applet#init()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * @see     java.applet.Applet#stop()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * @see     java.awt.Component#isShowing()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * @see     java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    public void start() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     * Called by the browser or applet viewer to inform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * this applet that it should stop its execution. It is called when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * the Web page that contains this applet has been replaced by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * another page, and also just before the applet is to be destroyed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * A subclass of <code>Applet</code> should override this method if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * it has any operation that it wants to perform each time the Web
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * page containing it is no longer visible. For example, an applet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * with animation might want to use the <code>start</code> method to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * resume animation, and the <code>stop</code> method to suspend the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * animation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * The implementation of this method provided by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * <code>Applet</code> class does nothing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * @see     java.applet.Applet#destroy()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * @see     java.applet.Applet#init()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    public void stop() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * Called by the browser or applet viewer to inform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * this applet that it is being reclaimed and that it should destroy
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * any resources that it has allocated. The <code>stop</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * will always be called before <code>destroy</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * A subclass of <code>Applet</code> should override this method if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * it has any operation that it wants to perform before it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * destroyed. For example, an applet with threads would use the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * <code>init</code> method to create the threads and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * <code>destroy</code> method to kill them.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     * The implementation of this method provided by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * <code>Applet</code> class does nothing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * @see     java.applet.Applet#init()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * @see     java.applet.Applet#start()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * @see     java.applet.Applet#stop()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    public void destroy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    // Accessibility support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    AccessibleContext accessibleContext = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * Gets the AccessibleContext associated with this Applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * For applets, the AccessibleContext takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * AccessibleApplet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * A new AccessibleApplet instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * @return an AccessibleApplet that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     *         AccessibleContext of this Applet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
            accessibleContext = new AccessibleApplet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * This class implements accessibility support for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * <code>Applet</code> class.  It provides an implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * Java Accessibility API appropriate to applet user-interface elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    protected class AccessibleApplet extends AccessibleAWTPanel {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        private static final long serialVersionUID = 8127374778187708896L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
         * Get the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
         * @return an instance of AccessibleRole describing the role of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
         * object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
            return AccessibleRole.FRAME;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
         * Get the state of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
         * @return an instance of AccessibleStateSet containing the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
         * state set of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
         * @see AccessibleState
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        public AccessibleStateSet getAccessibleStateSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
            AccessibleStateSet states = super.getAccessibleStateSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
            states.add(AccessibleState.ACTIVE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
            return states;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
}