Java Reference
In-Depth Information
The Applet Context
The applet context refers to the environment that the applet is running in, which
for most applets is a Web page. The java.applet.AppletContext interface con-
tains methods that an applet can use to communicate with the environment,
allowing the applet to perform tasks like finding another applet on the page or
loading a different Web page into the user's browser.
An applet obtains a reference to the AppletContext object using the
getAppletContext() method, found in the Applet class:
public AppletContext getAppletContext(). Returns a reference to this
applet's context, which is typically a Web document.
Here are some of the methods in the AppletContext interface.
public Applet getApplet(String name). Returns a reference to the applet
on this page that has the given name, which is determined by the name
attribute of the <applet> tag.
public void showDocument(URL url). Replaces the current Web page
with the document at the specified java.net.URL.
public void showDocument(URL url, String target). Shows the docu-
ment at the specified java.net.URL. The target parameter is an HTML
attribute that determines where the document is displayed. The possible
values are:
_self. Show the document in the same window and frame as the applet.
_parent. Show the document in the applet's parent frame.
_top. Show the document in the top-level frame of the applet's window.
_blank. Show the document in a new window.
“name”. Show the document in a currently opened browser window
with the given name. If a window does not match name , then the
document is shown in a new window.
public AudioClip getAudioClip(URL url). Creates a new AudioClip
object from the audio file at the specified URL. Audio clips are discussed
in the upcoming section Playing Audio .
public Image getImage(URL url). Returns an Image object associated
with the image file at the specified URL. Images are discussed in the
upcoming section Displaying Images .
public void showStatus(String status).
Displays the status String in the
status bar of the browser's window.
Search WWH ::




Custom Search