src/java.desktop/share/classes/java/applet/Applet.java
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 38470 jdk/src/java.desktop/share/classes/java/applet/Applet.java@6dd62dab450d
child 50345 276cb4b17f79
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
38470
6dd62dab450d 8157622: Add @Deprecated annotations to the Applet API classes
dtitov
parents: 35667
diff changeset
     2
 * Copyright (c) 1995, 2016, 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>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
    41
 * The {@code Applet} class must be the superclass of any
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * applet that is to be embedded in a Web page or viewed by the Java
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
    43
 * Applet Viewer. The {@code Applet} class provides a standard
2
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
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 24701
diff changeset
    48
 * @since       1.0
38470
6dd62dab450d 8157622: Add @Deprecated annotations to the Applet API classes
dtitov
parents: 35667
diff changeset
    49
 *
6dd62dab450d 8157622: Add @Deprecated annotations to the Applet API classes
dtitov
parents: 35667
diff changeset
    50
 * @deprecated  The Applet API is deprecated. See the
6dd62dab450d 8157622: Add @Deprecated annotations to the Applet API classes
dtitov
parents: 35667
diff changeset
    51
 * <a href="package-summary.html"> java.applet package documentation</a>
6dd62dab450d 8157622: Add @Deprecated annotations to the Applet API classes
dtitov
parents: 35667
diff changeset
    52
 * for further information.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 */
38470
6dd62dab450d 8157622: Add @Deprecated annotations to the Applet API classes
dtitov
parents: 35667
diff changeset
    54
6dd62dab450d 8157622: Add @Deprecated annotations to the Applet API classes
dtitov
parents: 35667
diff changeset
    55
@Deprecated(since = "9")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
public class Applet extends Panel {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * Constructs a new Applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
    61
     * Note: Many methods in {@code java.applet.Applet}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * may be invoked by the applet only after the applet is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * fully constructed; applet should avoid calling methods
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
    64
     * in {@code java.applet.Applet} in the constructor.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    public Applet() throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        if (GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            throw new HeadlessException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * Applets can be serialized but the following conventions MUST be followed:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * Before Serialization:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * An applet must be in STOPPED state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * After Deserialization:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * The applet will be restored in STOPPED state (and most clients will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * likely move it into RUNNING state).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * The stub field will be restored by the reader.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 25859
diff changeset
    88
    private transient AppletStub stub;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    /* version ID for serialized form. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    private static final long serialVersionUID = -5836846270535785031L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * Read an applet from an object input stream.
24701
62c52173dc2d 8040081: Tidy warnings cleanup for java.applet
yan
parents: 23010
diff changeset
    95
     * @param  s  an object input stream.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @exception HeadlessException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
    97
     * {@code GraphicsEnvironment.isHeadless()} returns
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
    98
     * {@code true}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    private void readObject(ObjectInputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        throws ClassNotFoundException, IOException, HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        if (GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            throw new HeadlessException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        s.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * Sets this applet's stub. This is done automatically by the system.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   113
     * <p>If there is a security manager, its {@code checkPermission}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * method is called with the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   115
     * {@code AWTPermission("setAppletStub")}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * permission if a stub has already been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @param   stub   the new stub.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * @exception SecurityException if the caller cannot set the stub
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    public final void setStub(AppletStub stub) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        if (this.stub != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            SecurityManager s = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            if (s != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                s.checkPermission(new AWTPermission("setAppletStub"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        }
11137
d5efdfdf72e0 7116993: fix warnings in java.applet
smarks
parents: 5506
diff changeset
   127
        this.stub = stub;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * Determines if this applet is active. An applet is marked active
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   132
     * just before its {@code start} method is called. It becomes
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   133
     * inactive just before its {@code stop} method is called.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   135
     * @return  {@code true} if the applet is active;
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   136
     *          {@code false} otherwise.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * @see     java.applet.Applet#start()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * @see     java.applet.Applet#stop()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    public boolean isActive() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        if (stub != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            return stub.isActive();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        } else {        // If stub field not filled in, applet never active
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * Gets the URL of the document in which this applet is embedded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * For example, suppose an applet is contained
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * within the document:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * <blockquote><pre>
20455
f6f9a0c2796b 8020688: Broken links in documentation at http://docs.oracle.com/javase/6/docs/api/index.
mcherkas
parents: 14342
diff changeset
   153
     *    http://www.oracle.com/technetwork/java/index.html
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * The document base is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * <blockquote><pre>
20455
f6f9a0c2796b 8020688: Broken links in documentation at http://docs.oracle.com/javase/6/docs/api/index.
mcherkas
parents: 14342
diff changeset
   157
     *    http://www.oracle.com/technetwork/java/index.html
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @return  the {@link java.net.URL} of the document that contains this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     *          applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * @see     java.applet.Applet#getCodeBase()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    public URL getDocumentBase() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        return stub.getDocumentBase();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * Gets the base URL. This is the URL of the directory which contains this applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * @return  the base {@link java.net.URL} of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     *          the directory which contains this applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * @see     java.applet.Applet#getDocumentBase()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    public URL getCodeBase() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        return stub.getCodeBase();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * Returns the value of the named parameter in the HTML tag. For
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * example, if this applet is specified as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * &lt;applet code="Clock" width=50 height=50&gt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * &lt;param name=Color value="blue"&gt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * &lt;/applet&gt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   188
     * then a call to {@code getParameter("Color")} returns the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   189
     * value {@code "blue"}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   191
     * The {@code name} argument is case insensitive.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * @param   name   a parameter name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * @return  the value of the named parameter,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   195
     *          or {@code null} if not set.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     public String getParameter(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
         return stub.getParameter(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * Determines this applet's context, which allows the applet to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * query and affect the environment in which it runs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * This environment of an applet represents the document that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * contains the applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * @return  the applet's context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    public AppletContext getAppletContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        return stub.getAppletContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * Requests that this applet be resized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * @param   width    the new requested width for the applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * @param   height   the new requested height for the applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     */
11137
d5efdfdf72e0 7116993: fix warnings in java.applet
smarks
parents: 5506
diff changeset
   220
    @SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    public void resize(int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        Dimension d = size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        if ((d.width != width) || (d.height != height)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            super.resize(width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            if (stub != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                stub.appletResize(width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * Requests that this applet be resized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * @param   d   an object giving the new width and height.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     */
11137
d5efdfdf72e0 7116993: fix warnings in java.applet
smarks
parents: 5506
diff changeset
   236
    @SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    public void resize(Dimension d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        resize(d.width, d.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    /**
4261
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   242
     * Indicates if this container is a validate root.
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   243
     * <p>
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   244
     * {@code Applet} objects are the validate roots, and, therefore, they
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   245
     * override this method to return {@code true}.
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   246
     *
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   247
     * @return {@code true}
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   248
     * @since 1.7
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   249
     * @see java.awt.Container#isValidateRoot
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   250
     */
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   251
    @Override
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   252
    public boolean isValidateRoot() {
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   253
        return true;
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   254
    }
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   255
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2
diff changeset
   256
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * Requests that the argument string be displayed in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * "status window". Many browsers and applet viewers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * provide such a window, where the application can inform users of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * its current state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * @param   msg   a string to display in the status window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    public void showStatus(String msg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        getAppletContext().showStatus(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   269
     * Returns an {@code Image} object that can then be painted on
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   270
     * the screen. The {@code url} that is passed as an argument
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * must specify an absolute URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * This method always returns immediately, whether or not the image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * exists. When this applet attempts to draw the image on the screen,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * the data will be loaded. The graphics primitives that draw the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * image will incrementally paint on the screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * @param   url   an absolute URL giving the location of the image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * @return  the image at the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * @see     java.awt.Image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    public Image getImage(URL url) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        return getAppletContext().getImage(url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   287
     * Returns an {@code Image} object that can then be painted on
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   288
     * the screen. The {@code url} argument must specify an absolute
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   289
     * URL. The {@code name} argument is a specifier that is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   290
     * relative to the {@code url} argument.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * This method always returns immediately, whether or not the image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * exists. When this applet attempts to draw the image on the screen,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * the data will be loaded. The graphics primitives that draw the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * image will incrementally paint on the screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * @param   url    an absolute URL giving the base location of the image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * @param   name   the location of the image, relative to the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   299
     *                 {@code url} argument.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * @return  the image at the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * @see     java.awt.Image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    public Image getImage(URL url, String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            return getImage(new URL(url, name));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        } catch (MalformedURLException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * Get an audio clip from the given URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * @param url points to the audio clip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * @return the audio clip at the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * @since       1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 25859
diff changeset
   319
    public static final AudioClip newAudioClip(URL url) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        return new sun.applet.AppletAudioClip(url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   324
     * Returns the {@code AudioClip} object specified by the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   325
     * {@code URL} argument.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * This method always returns immediately, whether or not the audio
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * clip exists. When this applet attempts to play the audio clip, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * data will be loaded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * @param   url  an absolute URL giving the location of the audio clip.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * @return  the audio clip at the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * @see     java.applet.AudioClip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    public AudioClip getAudioClip(URL url) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        return getAppletContext().getAudioClip(url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   340
     * Returns the {@code AudioClip} object specified by the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   341
     * {@code URL} and {@code name} arguments.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * This method always returns immediately, whether or not the audio
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * clip exists. When this applet attempts to play the audio clip, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * data will be loaded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * @param   url    an absolute URL giving the base location of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     *                 audio clip.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * @param   name   the location of the audio clip, relative to the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   350
     *                 {@code url} argument.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * @return  the audio clip at the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * @see     java.applet.AudioClip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    public AudioClip getAudioClip(URL url, String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            return getAudioClip(new URL(url, name));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        } catch (MalformedURLException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * Returns information about this applet. An applet should override
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   364
     * this method to return a {@code String} containing information
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * about the author, version, and copyright of the applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * The implementation of this method provided by the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   368
     * {@code Applet} class returns {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * @return  a string containing information about the author, version, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     *          copyright of the applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    public String getAppletInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * Gets the locale of the applet. It allows the applet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * to maintain its own locale separated from the locale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * of the browser or appletviewer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     * @return  the locale of the applet; if no locale has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     *          been set, the default locale is returned.
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 24701
diff changeset
   384
     * @since   1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    public Locale getLocale() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
      Locale locale = super.getLocale();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
      if (locale == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        return Locale.getDefault();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
      return locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * Returns information about the parameters that are understood by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * this applet. An applet should override this method to return an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   397
     * array of {@code Strings} describing these parameters.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * Each element of the array should be a set of three
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   400
     * {@code Strings} containing the name, the type, and a
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * description. For example:
21957
97758de70fbd 8028019: AWT Doclint warning/error cleanup
rriggs
parents: 20455
diff changeset
   402
     * <blockquote><pre>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * String pinfo[][] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     *   {"fps",    "1-10",    "frames per second"},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     *   {"repeat", "boolean", "repeat image loop"},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     *   {"imgs",   "url",     "images directory"}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * The implementation of this method provided by the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   411
     * {@code Applet} class returns {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * @return  an array describing the parameters this applet looks for.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    public String[][] getParameterInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * Plays the audio clip at the specified absolute URL. Nothing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * happens if the audio clip cannot be found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * @param   url   an absolute URL giving the location of the audio clip.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    public void play(URL url) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        AudioClip clip = getAudioClip(url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        if (clip != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
            clip.play();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * Plays the audio clip given the URL and a specifier that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * relative to it. Nothing happens if the audio clip cannot be found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * @param   url    an absolute URL giving the base location of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     *                 audio clip.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * @param   name   the location of the audio clip, relative to the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   439
     *                 {@code url} argument.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    public void play(URL url, String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        AudioClip clip = getAudioClip(url, name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        if (clip != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            clip.play();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * Called by the browser or applet viewer to inform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * this applet that it has been loaded into the system. It is always
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   451
     * called before the first time that the {@code start} method is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   454
     * A subclass of {@code Applet} should override this method if
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * it has initialization to perform. For example, an applet with
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   456
     * threads would use the {@code init} method to create the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   457
     * threads and the {@code destroy} method to kill them.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * The implementation of this method provided by the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   460
     * {@code Applet} class does nothing.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * @see     java.applet.Applet#destroy()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * @see     java.applet.Applet#start()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * @see     java.applet.Applet#stop()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    public void init() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * Called by the browser or applet viewer to inform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * this applet that it should start its execution. It is called after
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   472
     * the {@code init} method and each time the applet is revisited
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * in a Web page.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   475
     * A subclass of {@code Applet} should override this method if
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * it has any operation that it wants to perform each time the Web
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * page containing it is visited. For example, an applet with
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   478
     * animation might want to use the {@code start} method to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   479
     * resume animation, and the {@code stop} method to suspend the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * animation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   482
     * Note: some methods, such as {@code getLocationOnScreen}, can only
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * provide meaningful results if the applet is showing.  Because
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   484
     * {@code isShowing} returns {@code false} when the applet's
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   485
     * {@code start} is first called, methods requiring
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   486
     * {@code isShowing} to return {@code true} should be called from
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   487
     * a {@code ComponentListener}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * The implementation of this method provided by the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   490
     * {@code Applet} class does nothing.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * @see     java.applet.Applet#destroy()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * @see     java.applet.Applet#init()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * @see     java.applet.Applet#stop()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * @see     java.awt.Component#isShowing()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * @see     java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    public void start() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * Called by the browser or applet viewer to inform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * this applet that it should stop its execution. It is called when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * the Web page that contains this applet has been replaced by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * another page, and also just before the applet is to be destroyed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   507
     * A subclass of {@code Applet} should override this method if
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * it has any operation that it wants to perform each time the Web
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * page containing it is no longer visible. For example, an applet
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   510
     * with animation might want to use the {@code start} method to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   511
     * resume animation, and the {@code stop} method to suspend the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * animation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * The implementation of this method provided by the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   515
     * {@code Applet} class does nothing.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * @see     java.applet.Applet#destroy()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * @see     java.applet.Applet#init()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    public void stop() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     * Called by the browser or applet viewer to inform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     * this applet that it is being reclaimed and that it should destroy
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   526
     * any resources that it has allocated. The {@code stop} method
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   527
     * will always be called before {@code destroy}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   529
     * A subclass of {@code Applet} should override this method if
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * it has any operation that it wants to perform before it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * destroyed. For example, an applet with threads would use the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   532
     * {@code init} method to create the threads and the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   533
     * {@code destroy} method to kill them.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * The implementation of this method provided by the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   536
     * {@code Applet} class does nothing.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * @see     java.applet.Applet#init()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * @see     java.applet.Applet#start()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * @see     java.applet.Applet#stop()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    public void destroy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    // Accessibility support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
    AccessibleContext accessibleContext = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     * Gets the AccessibleContext associated with this Applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * For applets, the AccessibleContext takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * AccessibleApplet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * A new AccessibleApplet instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * @return an AccessibleApplet that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     *         AccessibleContext of this Applet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
            accessibleContext = new AccessibleApplet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * This class implements accessibility support for the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   570
     * {@code Applet} class.  It provides an implementation of the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * Java Accessibility API appropriate to applet user-interface elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
    protected class AccessibleApplet extends AccessibleAWTPanel {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        private static final long serialVersionUID = 8127374778187708896L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
         * Get the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
         * @return an instance of AccessibleRole describing the role of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
         * object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
            return AccessibleRole.FRAME;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
         * Get the state of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
         * @return an instance of AccessibleStateSet containing the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
         * state set of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
         * @see AccessibleState
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        public AccessibleStateSet getAccessibleStateSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
            AccessibleStateSet states = super.getAccessibleStateSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
            states.add(AccessibleState.ACTIVE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
            return states;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
}