Path: blob/master/src/java.desktop/share/classes/java/applet/AppletContext.java
41152 views
/*1* Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.applet;2627import java.awt.Image;28import java.io.IOException;29import java.io.InputStream;30import java.net.URL;31import java.util.Enumeration;32import java.util.Iterator;3334/**35* This interface corresponds to an applet's environment: the document36* containing the applet and the other applets in the same document.37* <p>38* The methods in this interface can be used by an applet to obtain information39* about its environment.40*41* @author Arthur van Hoff42* @since 1.043* @deprecated The Applet API is deprecated, no replacement.44*/45@Deprecated(since = "9", forRemoval = true)46@SuppressWarnings("removal")47public interface AppletContext {4849/**50* Creates an audio clip.51*52* @param url an absolute {@code URL} giving the location of the audio clip53* @return the audio clip at the specified {@code URL}54*/55AudioClip getAudioClip(URL url);5657/**58* Returns an {@code Image} object that can then be painted on the screen.59* The {@code url} argument that is passed as an argument must specify an60* absolute {@code URL}.61* <p>62* This method always returns immediately, whether or not the image exists.63* When the applet attempts to draw the image on the screen, the data will64* be loaded. The graphics primitives that draw the image will incrementally65* paint on the screen.66*67* @param url an absolute {@code URL} giving the location of the image68* @return the image at the specified {@code URL}69* @see java.awt.Image70*/71Image getImage(URL url);7273/**74* Finds and returns the applet in the document represented by this applet75* context with the given name. The name can be set in the HTML tag by76* setting the {@code name} attribute.77*78* @param name an applet name79* @return the applet with the given name, or {@code null} if not found80*/81Applet getApplet(String name);8283/**84* Finds all the applets in the document represented by this applet context.85*86* @return an enumeration of all applets in the document represented by this87* applet context88*/89Enumeration<Applet> getApplets();9091/**92* Requests that the browser or applet viewer show the Web page indicated by93* the {@code url} argument. The browser or applet viewer determines which94* window or frame to display the Web page. This method may be ignored by95* applet contexts that are not browsers.96*97* @param url an absolute {@code URL} giving the location of the document98*/99void showDocument(URL url);100101/**102* Requests that the browser or applet viewer show the Web page indicated by103* the {@code url} argument. The {@code target} argument indicates in which104* HTML frame the document is to be displayed. The target argument is105* interpreted as follows:106*107* <table class="striped">108* <caption>Target arguments and their descriptions</caption>109* <thead>110* <tr>111* <th scope="col">Target Argument112* <th scope="col">Description113* </thead>114* <tbody>115* <tr>116* <th scope="row">{@code "_self"}117* <td>Show in the window and frame that contain the applet.118* <tr>119* <th scope="row">{@code "_parent"}120* <td>Show in the applet's parent frame. If the applet's frame has no121* parent frame, acts the same as "_self".122* <tr>123* <th scope="row">{@code "_top"}124* <td>Show in the top-level frame of the applet's window. If the125* applet's frame is the top-level frame, acts the same as "_self".126* <tr>127* <th scope="row">{@code "_blank"}128* <td>Show in a new, unnamed top-level window.129* <tr>130* <th scope="row"><i>name</i>131* <td>Show in the frame or window named <i>name</i>. If a target named132* <i>name</i> does not already exist, a new top-level window with the133* specified name is created, and the document is shown there.134* </tbody>135* </table>136* <p>137* An applet viewer or browser is free to ignore {@code showDocument}.138*139* @param url an absolute {@code URL} giving the location of the document140* @param target a {@code String} indicating where to display the page141*/142public void showDocument(URL url, String target);143144/**145* Requests that the argument string be displayed in the "status window".146* Many browsers and applet viewers provide such a window, where the147* application can inform users of its current state.148*149* @param status a string to display in the status window150*/151void showStatus(String status);152153/**154* Associates the specified stream with the specified key in this applet155* context. If the applet context previously contained a mapping for this156* key, the old value is replaced.157* <p>158* For security reasons, mapping of streams and keys exists for each159* codebase. In other words, applet from one codebase cannot access the160* streams created by an applet from a different codebase161*162* @param key key with which the specified value is to be associated163* @param stream stream to be associated with the specified key. If this164* parameter is {@code null}, the specified key is removed in this165* applet context.166* @throws IOException if the stream size exceeds a certain size limit. Size167* limit is decided by the implementor of this interface.168* @since 1.4169*/170public void setStream(String key, InputStream stream) throws IOException;171172/**173* Returns the stream to which specified key is associated within this174* applet context. Returns {@code null} if the applet context contains no175* stream for this key.176* <p>177* For security reasons, mapping of streams and keys exists for each178* codebase. In other words, applet from one codebase cannot access the179* streams created by an applet from a different codebase.180*181* @param key key whose associated stream is to be returned182* @return the stream to which this applet context maps the key183* @since 1.4184*/185public InputStream getStream(String key);186187/**188* Finds all the keys of the streams in this applet context.189* <p>190* For security reasons, mapping of streams and keys exists for each191* codebase. In other words, applet from one codebase cannot access the192* streams created by an applet from a different codebase.193*194* @return an {@code Iterator} of all the names of the streams in this195* applet context196* @since 1.4197*/198public Iterator<String> getStreamKeys();199}200201202