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