Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/applet/AppletContext.java
38829 views
/*1* Copyright (c) 1995, 2013, 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.awt.Graphics;29import java.awt.image.ColorModel;30import java.net.URL;31import java.util.Enumeration;32import java.io.InputStream;33import java.io.IOException;34import java.util.Iterator;3536/**37* This interface corresponds to an applet's environment: the38* document containing the applet and the other applets in the same39* document.40* <p>41* The methods in this interface can be used by an applet to obtain42* information about its environment.43*44* @author Arthur van Hoff45* @since JDK1.046*/47public interface AppletContext {48/**49* Creates an audio clip.50*51* @param url an absolute URL giving the location of the audio clip.52* @return the audio clip at the specified URL.53*/54AudioClip getAudioClip(URL url);5556/**57* Returns an <code>Image</code> object that can then be painted on58* the screen. The <code>url</code> argument that is59* passed as an argument must specify an absolute URL.60* <p>61* This method always returns immediately, whether or not the image62* exists. When the applet attempts to draw the image on the screen,63* the data will be loaded. The graphics primitives that draw the64* image will incrementally paint on the screen.65*66* @param url an absolute URL giving the location of the image.67* @return the image at the specified URL.68* @see java.awt.Image69*/70Image getImage(URL url);7172/**73* Finds and returns the applet in the document represented by this74* applet context with the given name. The name can be set in the75* HTML tag by setting the <code>name</code> attribute.76*77* @param name an applet name.78* @return the applet with the given name, or <code>null</code> if79* not found.80*/81Applet getApplet(String name);8283/**84* Finds all the applets in the document represented by this applet85* context.86*87* @return an enumeration of all applets in the document represented by88* this applet context.89*/90Enumeration<Applet> getApplets();9192/**93* Requests that the browser or applet viewer show the Web page94* indicated by the <code>url</code> argument. The browser or95* applet viewer determines which window or frame to display the96* Web page. This method may be ignored by applet contexts that97* are not browsers.98*99* @param url an absolute URL giving the location of the document.100*/101void showDocument(URL url);102103/**104* Requests that the browser or applet viewer show the Web page105* indicated by the <code>url</code> argument. The106* <code>target</code> argument indicates in which HTML frame the107* document is to be displayed.108* The target argument is interpreted as follows:109*110* <center><table border="3" summary="Target arguments and their descriptions">111* <tr><th>Target Argument</th><th>Description</th></tr>112* <tr><td><code>"_self"</code> <td>Show in the window and frame that113* contain the applet.</tr>114* <tr><td><code>"_parent"</code><td>Show in the applet's parent frame. If115* the applet's frame has no parent frame,116* acts the same as "_self".</tr>117* <tr><td><code>"_top"</code> <td>Show in the top-level frame of the applet's118* window. If the applet's frame is the119* top-level frame, acts the same as "_self".</tr>120* <tr><td><code>"_blank"</code> <td>Show in a new, unnamed121* top-level window.</tr>122* <tr><td><i>name</i><td>Show in the frame or window named <i>name</i>. If123* a target named <i>name</i> does not already exist, a124* new top-level window with the specified name is created,125* and the document is shown there.</tr>126* </table> </center>127* <p>128* An applet viewer or browser is free to ignore <code>showDocument</code>.129*130* @param url an absolute URL giving the location of the document.131* @param target a <code>String</code> indicating where to display132* the page.133*/134public void showDocument(URL url, String target);135136/**137* Requests that the argument string be displayed in the138* "status window". Many browsers and applet viewers139* provide such a window, where the application can inform users of140* its current state.141*142* @param status a string to display in the status window.143*/144void showStatus(String status);145146/**147* Associates the specified stream with the specified key in this148* applet context. If the applet context previously contained a mapping149* for this key, the old value is replaced.150* <p>151* For security reasons, mapping of streams and keys exists for each152* codebase. In other words, applet from one codebase cannot access153* the streams created by an applet from a different codebase154* <p>155* @param key key with which the specified value is to be associated.156* @param stream stream to be associated with the specified key. If this157* parameter is <code>null</code>, the specified key is removed158* in this applet context.159* @throws IOException if the stream size exceeds a certain160* size limit. Size limit is decided by the implementor of this161* interface.162* @since 1.4163*/164public void setStream(String key, InputStream stream)throws IOException;165166/**167* Returns the stream to which specified key is associated within this168* applet context. Returns <tt>null</tt> if the applet context contains169* no stream for this key.170* <p>171* For security reasons, mapping of streams and keys exists for each172* codebase. In other words, applet from one codebase cannot access173* the streams created by an applet from a different codebase174* <p>175* @return the stream to which this applet context maps the key176* @param key key whose associated stream is to be returned.177* @since 1.4178*/179public InputStream getStream(String key);180181/**182* Finds all the keys of the streams in this applet context.183* <p>184* For security reasons, mapping of streams and keys exists for each185* codebase. In other words, applet from one codebase cannot access186* the streams created by an applet from a different codebase187* <p>188* @return an Iterator of all the names of the streams in this applet189* context.190* @since 1.4191*/192public Iterator<String> getStreamKeys();193}194195196