jdk/src/share/classes/java/applet/Applet.java
author alanb
Fri, 02 Nov 2012 15:50:11 +0000
changeset 14342 8435a30053c1
parent 11137 d5efdfdf72e0
child 20455 f6f9a0c2796b
permissions -rw-r--r--
7197491: update copyright year to match last edit in jdk8 jdk repository Reviewed-by: chegar, ksrini
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 11137
diff changeset
     2
 * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
2
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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4261
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4261
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4261
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4261
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4261
diff changeset
    23
 * questions.
2
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
        }
11137
d5efdfdf72e0 7116993: fix warnings in java.applet
smarks
parents: 5506
diff changeset
   120
        this.stub = stub;
2
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
     */
11137
d5efdfdf72e0 7116993: fix warnings in java.applet
smarks
parents: 5506
diff changeset
   213
    @SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    public void resize(int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        Dimension d = size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        if ((d.width != width) || (d.height != height)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            super.resize(width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            if (stub != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                stub.appletResize(width, height);
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * Requests that this applet be resized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * @param   d   an object giving the new width and height.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     */
11137
d5efdfdf72e0 7116993: fix warnings in java.applet
smarks
parents: 5506
diff changeset
   229
    @SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    public void resize(Dimension d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        resize(d.width, d.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    /**
4261
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   235
     * Indicates if this container is a validate root.
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   236
     * <p>
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   237
     * {@code Applet} objects are the validate roots, and, therefore, they
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   238
     * override this method to return {@code true}.
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   239
     *
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   240
     * @return {@code true}
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   241
     * @since 1.7
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   242
     * @see java.awt.Container#isValidateRoot
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   243
     */
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   244
    @Override
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   245
    public boolean isValidateRoot() {
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   246
        return true;
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   247
    }
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   248
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   249
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * Requests that the argument string be displayed in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * "status window". Many browsers and applet viewers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * provide such a window, where the application can inform users of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * its current state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * @param   msg   a string to display in the status window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    public void showStatus(String msg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        getAppletContext().showStatus(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * Returns an <code>Image</code> object that can then be painted on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * the screen. The <code>url</code> that is passed as an argument
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * must specify an absolute URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * This method always returns immediately, whether or not the image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * exists. When this applet attempts to draw the image on the screen,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * the data will be loaded. The graphics primitives that draw the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * image will incrementally paint on the screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * @param   url   an absolute URL giving the location of the image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * @return  the image at the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * @see     java.awt.Image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    public Image getImage(URL url) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        return getAppletContext().getImage(url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * Returns an <code>Image</code> object that can then be painted on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * the screen. The <code>url</code> argument must specify an absolute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * URL. The <code>name</code> argument is a specifier that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * relative to the <code>url</code> argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * This method always returns immediately, whether or not the image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * exists. When this applet attempts to draw the image on the screen,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * the data will be loaded. The graphics primitives that draw the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * image will incrementally paint on the screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * @param   url    an absolute URL giving the base location of the image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * @param   name   the location of the image, relative to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     *                 <code>url</code> argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * @return  the image at the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * @see     java.awt.Image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    public Image getImage(URL url, String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
            return getImage(new URL(url, name));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        } catch (MalformedURLException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * Get an audio clip from the given URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * @param url points to 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
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * @since       1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    public final static AudioClip newAudioClip(URL url) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        return new sun.applet.AppletAudioClip(url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * Returns the <code>AudioClip</code> object specified by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * <code>URL</code> argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * This method always returns immediately, whether or not the audio
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * clip exists. When this applet attempts to play the audio clip, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * data will be loaded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * @param   url  an absolute URL giving the location of the audio clip.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * @return  the audio clip at the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * @see     java.applet.AudioClip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    public AudioClip getAudioClip(URL url) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        return getAppletContext().getAudioClip(url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * Returns the <code>AudioClip</code> object specified by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * <code>URL</code> and <code>name</code> arguments.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * This method always returns immediately, whether or not the audio
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * clip exists. When this applet attempts to play the audio clip, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * data will be loaded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * @param   url    an absolute URL giving the base location of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     *                 audio clip.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * @param   name   the location of the audio clip, relative to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     *                 <code>url</code> argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * @return  the audio clip at the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * @see     java.applet.AudioClip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    public AudioClip getAudioClip(URL url, String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
            return getAudioClip(new URL(url, name));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        } catch (MalformedURLException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * Returns information about this applet. An applet should override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * this method to return a <code>String</code> containing information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * about the author, version, and copyright of the applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * The implementation of this method provided by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * <code>Applet</code> class returns <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * @return  a string containing information about the author, version, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     *          copyright of the applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    public String getAppletInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        return null;
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
     * Gets the locale of the applet. It allows the applet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * to maintain its own locale separated from the locale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * of the browser or appletviewer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * @return  the locale of the applet; if no locale has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     *          been set, the default locale is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * @since   JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    public Locale getLocale() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
      Locale locale = super.getLocale();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
      if (locale == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        return Locale.getDefault();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
      return locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * Returns information about the parameters that are understood by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * this applet. An applet should override this method to return an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * array of <code>Strings</code> describing these parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * Each element of the array should be a set of three
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * <code>Strings</code> containing the name, the type, and a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * description. For example:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * <p><blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * String pinfo[][] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     *   {"fps",    "1-10",    "frames per second"},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     *   {"repeat", "boolean", "repeat image loop"},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     *   {"imgs",   "url",     "images directory"}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * The implementation of this method provided by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * <code>Applet</code> class returns <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * @return  an array describing the parameters this applet looks for.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    public String[][] getParameterInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * Plays the audio clip at the specified absolute URL. Nothing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * happens if the audio clip cannot be found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * @param   url   an absolute URL giving the location of the audio clip.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    public void play(URL url) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        AudioClip clip = getAudioClip(url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        if (clip != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
            clip.play();
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * Plays the audio clip given the URL and a specifier that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * relative to it. Nothing happens if the audio clip cannot be found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * @param   url    an absolute URL giving the base location of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     *                 audio clip.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * @param   name   the location of the audio clip, relative to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     *                 <code>url</code> argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    public void play(URL url, String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        AudioClip clip = getAudioClip(url, name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        if (clip != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            clip.play();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * Called by the browser or applet viewer to inform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * this applet that it has been loaded into the system. It is always
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * called before the first time that the <code>start</code> method is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * A subclass of <code>Applet</code> should override this method if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * it has initialization to perform. For example, an applet with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * threads would use the <code>init</code> method to create the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * threads and the <code>destroy</code> method to kill them.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * The implementation of this method provided by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * <code>Applet</code> class does nothing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * @see     java.applet.Applet#destroy()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * @see     java.applet.Applet#start()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * @see     java.applet.Applet#stop()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    public void init() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * Called by the browser or applet viewer to inform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * this applet that it should start its execution. It is called after
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * the <code>init</code> method and each time the applet is revisited
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * in a Web page.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * A subclass of <code>Applet</code> should override this method if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * it has any operation that it wants to perform each time the Web
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * page containing it is visited. For example, an applet with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * animation might want to use the <code>start</code> method to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * resume animation, and the <code>stop</code> method to suspend the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * animation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * Note: some methods, such as <code>getLocationOnScreen</code>, can only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * provide meaningful results if the applet is showing.  Because
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * <code>isShowing</code> returns <code>false</code> when the applet's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     * <code>start</code> is first called, methods requiring
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * <code>isShowing</code> to return <code>true</code> should be called from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * a <code>ComponentListener</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * The implementation of this method provided by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * <code>Applet</code> class does nothing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * @see     java.applet.Applet#destroy()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * @see     java.applet.Applet#init()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * @see     java.applet.Applet#stop()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * @see     java.awt.Component#isShowing()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * @see     java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    public void start() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * Called by the browser or applet viewer to inform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * this applet that it should stop its execution. It is called when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * the Web page that contains this applet has been replaced by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * another page, and also just before the applet is to be destroyed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * A subclass of <code>Applet</code> should override this method if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * it has any operation that it wants to perform each time the Web
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * page containing it is no longer visible. For example, an applet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * with animation might want to use the <code>start</code> method to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * resume animation, and the <code>stop</code> method to suspend the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * animation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * The implementation of this method provided by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * <code>Applet</code> class does nothing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * @see     java.applet.Applet#destroy()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     * @see     java.applet.Applet#init()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    public void stop() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * Called by the browser or applet viewer to inform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * this applet that it is being reclaimed and that it should destroy
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * any resources that it has allocated. The <code>stop</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     * will always be called before <code>destroy</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * A subclass of <code>Applet</code> should override this method if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * it has any operation that it wants to perform before it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     * destroyed. For example, an applet with threads would use the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     * <code>init</code> method to create the threads and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     * <code>destroy</code> method to kill them.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * The implementation of this method provided by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * <code>Applet</code> class does nothing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * @see     java.applet.Applet#init()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * @see     java.applet.Applet#start()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * @see     java.applet.Applet#stop()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    public void destroy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    // Accessibility support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    AccessibleContext accessibleContext = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * Gets the AccessibleContext associated with this Applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * For applets, the AccessibleContext takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * AccessibleApplet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     * A new AccessibleApplet instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * @return an AccessibleApplet that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     *         AccessibleContext of this Applet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
            accessibleContext = new AccessibleApplet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * This class implements accessibility support for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * <code>Applet</code> class.  It provides an implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * Java Accessibility API appropriate to applet user-interface elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
    protected class AccessibleApplet extends AccessibleAWTPanel {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        private static final long serialVersionUID = 8127374778187708896L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
         * Get the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
         * @return an instance of AccessibleRole describing the role of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
         * object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
        public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
            return AccessibleRole.FRAME;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
         * Get the state of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
         * @return an instance of AccessibleStateSet containing the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
         * state set of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
         * @see AccessibleState
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        public AccessibleStateSet getAccessibleStateSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            AccessibleStateSet states = super.getAccessibleStateSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
            states.add(AccessibleState.ACTIVE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
            return states;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
}