Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.applet

Class Applet

java.lang.Object
|
+--java.awt.Component
   |
   +--java.awt.Container
      |
      +--java.awt.Panel
         |
         +--java.applet.Applet


public class Applet

extends Panel

This is the base applet class. An applet is a Java program that runs inside a web browser or other applet viewer in a restricted environment.

To be useful, a subclass should override at least start(). Also useful are init, stop, and destroy for control purposes, and getAppletInfo and getParameterInfo for descriptive purposes.

Since:Authors:

Constructor Summary

Applet()

Default constructor for subclasses.

Method Summary

voiddestroy()

This method is called when the applet is being unloaded.
javax.accessibility.AccessibleContextgetAccessibleContext()

Gets the AccessibleContext associated with this applet, creating one if necessary.
java.applet.AppletContextgetAppletContext()

Returns the applet context for this applet.
java.lang.StringgetAppletInfo()

Returns a descriptive string with applet defined information.
java.applet.AudioClipgetAudioClip(java.net.URL url)

Returns an audio clip from the specified URL.
java.applet.AudioClipgetAudioClip(java.net.URL url, java.lang.String name)

Returns an audio clip from the specified absolute URL, and relative path from that URL.
java.net.URLgetCodeBase()

Returns the URL of the code base for this applet.
java.net.URLgetDocumentBase()

Returns the basename URL of the document this applet is embedded in.
java.awt.ImagegetImage(java.net.URL url)

Returns an image from the specified URL.
java.awt.ImagegetImage(java.net.URL url, java.lang.String name)

Returns an image from the specified absolute URL, and relative path from that URL.
java.util.LocalegetLocale()

Returns the locale for this applet, if it has been set.
java.lang.StringgetParameter(java.lang.String name)

Returns the value of the specified parameter that was specified in the <APPLET> tag for this applet.
java.lang.String[][]getParameterInfo()

Returns a list of parameters this applet supports.
voidinit()

This method is called when the applet is first loaded, before start().
booleanisActive()

Tests whether or not this applet is currently active.
static java.applet.AudioClipnewAudioClip(java.net.URL url)

Returns an audio clip from the specified URL.
voidplay(java.net.URL url)

Loads and plays the audio clip pointed to by the specified URL.
voidplay(java.net.URL url, java.lang.String name)

Loads and plays the audio clip pointed to by the specified absolute URL, and relative path from that URL.
voidresize(int width, int height)

Requests that the applet window for this applet be resized.
voidresize(java.awt.Dimension dim)

Requests that the applet window for this applet be resized.
voidsetStub(java.applet.AppletStub stub)

The browser calls this method to set the applet's stub, which is the low level interface to the browser.
voidshowStatus(java.lang.String message)

Displays the specified message in the status window if that window exists.
voidstart()

This method is called when the applet should start running.
voidstop()

This method is called when the applet should stop running.

Constructor Details

Applet

public Applet()

Default constructor for subclasses.

Throws:


Method Details

destroy

public void destroy()

This method is called when the applet is being unloaded. The default implementation does nothing; override for your applet to clean up resources on exit.

See Also:


getAccessibleContext

public AccessibleContext getAccessibleContext()

Gets the AccessibleContext associated with this applet, creating one if necessary. This always returns an instance of AccessibleApplet.

Since:Returns:


getAppletContext

public AppletContext getAppletContext()

Returns the applet context for this applet.

Returns:


getAppletInfo

public String getAppletInfo()

Returns a descriptive string with applet defined information. The implementation in this class returns null, so subclasses must override to return information.

Returns:


getAudioClip

public AudioClip getAudioClip(java.net.URL url)

Returns an audio clip from the specified URL. Note that the clip is not actually retrieved until the applet attempts to play it, so this method returns immediately.

Parameters:

Returns:

Throws:


getAudioClip

public AudioClip getAudioClip(java.net.URL url, java.lang.String name)

Returns an audio clip from the specified absolute URL, and relative path from that URL. Note that the clip is not actually retrieved until the applet attempts to play it, so this method returns immediately. This calls getAudioClip(new URL(url, name)), but if building the new URL fails, this returns null.

Parameters:

Returns:

See Also:


getCodeBase

public URL getCodeBase()

Returns the URL of the code base for this applet.

Returns:


getDocumentBase

public URL getDocumentBase()

Returns the basename URL of the document this applet is embedded in. This is everything up to the final '/'.

Returns:

See Also:


getImage

public Image getImage(java.net.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:

Returns:

Throws:


getImage

public Image getImage(java.net.URL url, java.lang.String name)

Returns an image from the specified absolute URL, and relative path from that URL. Note that the image is not actually retrieved until the applet attempts to display it, so this method returns immediately. This calls getImage(new URL(url, name)), but if building the new URL fails, this returns null.

Parameters:

Returns:

See Also:


getLocale

public Locale getLocale()

Returns the locale for this applet, if it has been set. If no applet specific locale has been set, the default locale is returned.

Since:Returns:

See Also:


getParameter

public String getParameter(java.lang.String name)

Returns the value of the specified parameter that was specified in the <APPLET> tag for this applet.

Parameters:

Returns:

Throws:


getParameterInfo

public String[][] getParameterInfo()

Returns a list of parameters this applet supports. Each element of the outer array is an array of three strings with the name of the parameter, the data type or valid values, and a description. This method is optional and the default implementation returns null.

Returns:


init

public void init()

This method is called when the applet is first loaded, before start(). The default implementation does nothing; override to do any one-time initialization.

See Also:


isActive

public boolean isActive()

Tests whether or not this applet is currently active. An applet is active just before the browser invokes start(), and becomes inactive just before the browser invokes stop().

Returns:


newAudioClip

public static final AudioClip newAudioClip(java.net.URL url)

Returns an audio clip from the specified URL. This clip is not tied to any particular applet. XXX Classpath does not yet implement this.

Since:Parameters:

Returns:

Throws:

See Also:


play

public void play(java.net.URL url)

Loads and plays the audio clip pointed to by the specified URL. This does nothing if the URL does not point to a valid audio clip.

Parameters:

Throws:

See Also:


play

public void play(java.net.URL url, java.lang.String name)

Loads and plays the audio clip pointed to by the specified absolute URL, and relative path from that URL. This does nothing if the URL cannot be constructed, or if it does not point to a valid audio clip.

Parameters:

See Also:


resize

public void resize(int width, int height)

Requests that the applet window for this applet be resized.

Parameters:


resize

public void resize(java.awt.Dimension dim)

Requests that the applet window for this applet be resized.

Parameters:

Throws:


setStub

public final void setStub(java.applet.AppletStub stub)

The browser calls this method to set the applet's stub, which is the low level interface to the browser. Manually setting this to null is asking for problems down the road.

Parameters:


showStatus

public void showStatus(java.lang.String message)

Displays the specified message in the status window if that window exists.

Parameters:


start

public void start()

This method is called when the applet should start running. This is normally each time a web page containing it is loaded. The default implemention does nothing; override for your applet to be useful.

See Also:


stop

public void stop()

This method is called when the applet should stop running. This is normally when the next web page is loaded. The default implementation does nothing; override for your applet to stop using resources when it is no longer visible, but may be restarted soon.

See Also: