java.applet
Interface AppletContext


public interface AppletContext

This interface allows an applet access to the browser to retrieve additional data files and display documents. It also allows the applet to find out other applets in the same document.

Since:
1.0

Method Summary
 Applet getApplet(String name)
          Returns the applet in the document for this object that has the specified name.
 Enumeration<Applet> getApplets()
          Returns a list of all the applets in the document for this object.
 AudioClip getAudioClip(URL url)
          Returns an audio clip from the specified URL.
 Image getImage(URL url)
          Returns an image from the specified URL.
 InputStream getStream(String key)
          Return the stream associated with a given key in this applet context, or null if nothing is associated.
 Iterator<String> getStreamKeys()
          Iterate over all keys that have associated streams.
 void setStream(String key, InputStream stream)
          Associate a stream to a key for this applet context, possibly replacing the old value.
 void showDocument(URL url)
          Displays the web page pointed to by the specified URL in the window for this object.
 void showDocument(URL url, String target)
          Displays the web page pointed to be the sepcified URL in the window with the specified name.
 void showStatus(String message)
          Displays the specified message in the status window if that window exists.
 

Method Detail

getAudioClip

AudioClip getAudioClip(URL url)
Returns an audio clip from the specified URL.

Parameters:
url - the URL of the audio clip
Returns:
the retrieved audio clip
Throws:
NullPointerException - if url is null

getImage

Image getImage(URL url)
Returns an image from the specified URL. Note that the image is not actually retrieved until the applet attempts to display it, so this method returns immediately.

Parameters:
url - the absolute URL of the image
Returns:
the retrieved image
Throws:
NullPointerException - if url is null

getApplet

Applet getApplet(String name)
Returns the applet in the document for this object that has the specified name.

Parameters:
name - the applet name
Returns:
the requested applet, or null if not found

getApplets

Enumeration<Applet> getApplets()
Returns a list of all the applets in the document for this object.

Returns:
a list of all the applets

showDocument

void showDocument(URL url)
Displays the web page pointed to by the specified URL in the window for this object. This page replaces the document that is currently there.

Parameters:
url - the URL of the web page to load; unspecified on an error

showDocument

void showDocument(URL url,
                  String target)
Displays the web page pointed to be the sepcified URL in the window with the specified name. The standard names "_top", "_blank", "_parent", and "_self" are allowed. An applet viewer may disregard this request.

Parameters:
url - the URL of the web page to load
target - the target window

showStatus

void showStatus(String message)
Displays the specified message in the status window if that window exists.

Parameters:
message - the status message, may be null

setStream

void setStream(String key,
               InputStream stream)
               throws IOException
Associate a stream to a key for this applet context, possibly replacing the old value. Stream associations are local to the applet context, for security purposes.

Parameters:
key - the key to associate with
stream - the stream value to tie to the key, or null to remove
Throws:
IOException - if the stream is too large
Since:
1.4

getStream

InputStream getStream(String key)
Return the stream associated with a given key in this applet context, or null if nothing is associated. Stream associations are local to the applet context, for security purposes.

Parameters:
key - the key to look up
Returns:
the associated stream, or null
Since:
1.4

getStreamKeys

Iterator<String> getStreamKeys()
Iterate over all keys that have associated streams. Stream associated are local to the applet context, for security purposes.

Returns:
an iterator over the association keys
Since:
1.4