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