Brought to you by EarthWeb
IT Library Logo

Click Here!
Click Here!

nav

EarthWeb Direct

EarthWeb Direct

EarthWeb sites: other sites

appendix E

java.applet Package Reference


CONTENTS

The java.applet package contains the necessary support for graphical Java applets that execute within the confines of a Web page.

AppletContext

The AppletContext interface is provided to give information on an applet's environment. An AppletContext interface can be obtained by calling the Applet class's getAppletContext method.

getAudioClip

public abstract AudioClip getAudioClip(URL url)
getAudioClip
retrieves an AudioClip based on the URL input parameter.
Parameters: url-a URL object containing location information for the clip to be retrieved.
Returns: An AudioClip object that can be played at a later time.

getImage

public abstract Image getImage(URL url)
getImage
retrieves image information based on the URL input parameter. Note that this function returns immediately and does not retrieve the entire image. This image will not be retrieved until the Image object is actually needed.
Parameters: url-a URL object containing location information for the image to be retrieved.
Returns: An Image object containing information about the URL passed in.

getApplet

public abstract Applet getApplet(String name)
getApplet
returns an Applet object from the current AppletContext based on the input name argument.
Parameters: name-a String object representing an applet's name. This name should correspond to the applet's HTML name attribute.
Returns: An Applet object or null if no applet exists with the designated name.

getApplets

public abstract Enumeration getApplets()
getApplets
returns an Enumeration interface for all the applets on the current AppletContext.
Returns: An Enumeration interface that can be used to retrieve all the applets on the current applet context.

showDocument

public abstract void showDocument(URL url)
showDocument
will load the URL argument into the current AppletContext if it is a valid URL. This method may be ignored, depending on the applet context.
Parameters: url-a URL object containing location information for the image to be retrieved.

showDocument

public abstract void showDocument(URL url, String target)
This showDocument method will load the URL argument into a target window or frame depending on the target string. This method may be ignored, depending on the applet context.
Parameters:
url-a URL object containing location information for the image to be retrieved.
target-the target string, which can be one of the following values:
  • "_self"-show in current frame.
  • "_parent"-show in parent frame.
  • "_top"-show in top-most frame.
  • "_blank"-show in new unnamed top-level window.
  • <other>-show in new top-level window named <other>.

showStatus

public abstract void showStatus(String status)
showStatus
shows a status message using the applet's context.
Parameters: msg-a string containing the message to be displayed.

AppletStub

The java.applet.AppletStub interface is most often used as an interface to build applet viewers, browsers, or other tools that want to display applets within them. This interface is not normally implemented by Java applet developers.

isActive

public abstract boolean isActive()
isActive
is used to determine whether this applet is currently active.
Returns: true if the applet is active, false if not.

getDocumentBase

public abstract URL getDocumentBase()
getDocumentBase
returns the URL of the current page that this applet is embedded in.
Returns: A URL object containing information about the current URL.

getCodeBase

public abstract URL getCodeBase()
getCodeBase
returns the URL of the applet itself.
Returns: A URL object containing information about the applet's URL.

getParameter

public abstract String getParameter(String name)
getParameter returns the String value of the parameter passed in using the HTML
<PARAM> tag.

getAppletContext

public abstract AppletContext getAppletContext()
getAppletContext
returns an AppletContext object. This object can be used to determine information about the applet's runtime environment.
Returns: An AppletContext object.

appletResize

public abstract void appletResize(int width, int height)
appletResize
is called when the applet wants to be resized.
Parameters:
width-an integer value specifying the applet's new width.
height-an integer value specifying the applet's new height.

AudioClip

The AudioClip interface is used to provide high-level access to sound playback capabilities. This interface, like AppletContext and AppletStub, is usually implemented only by applet viewers.

play

public abstract void play()
The play method plays audio files from the beginning until the end or stop method is called.

loop

public abstract void loop()
The loop method plays audio files in a loop continuously.

stop

public abstract void stop()
The stop method stops the playing of an audio file.

Applet

Extends: Panel
This implies that every applet has some visual component. The basic visual component is a panel in an HTML page.

Applet

public Applet()
This is the default constructor for the Applet class. This function creates a new applet. Each applet should implement at a minimum the init or start methods to display themselves on the screen and for initial setup.

setStub

public final void setStub(AppletStub stub)
setStub
sets the AppletStub to the stub passed in. This function is called automatically by the underlying system and usually is not called directly. The only time AppletStub methods need to be implemented is if you are writing your own applet viewer or browser.
Parameters: stub-the underlying stub used to implement an applet viewer.

isActive

public boolean isActive()
isActive
is used to determine whether this applet is currently active. An applet is set Active just before the Start method is called.

getDocumentBase

public URL getDocumentBase()
getDocumentBase
returns the URL of the current page that this applet is embedded in.
Returns: A URL object containing information about the current URL.

getCodeBase

public URL getCodeBase()
getCodeBase
returns the URL of the applet itself.
Returns: A URL object containing information about the applet's URL.

getParameter

public String getParameter(String name)
getParameter
returns the String value of the parameter passed in using the HTML
<PARAM> tag.
Parameters: name-a case-sensitive string that matches (exactly!) the parameter name passed in using the HTML PARAM tag.
Returns: A string value representing the PARAM tag's VALUE attribute.

getAppletContext

public AppletContext getAppletContext()
getAppletContext
returns an AppletContext object. This object can be used to determine information about the applet's runtime environment.
Returns: An AppletContext object.

resize

public void resize(int width, int height)
resize
makes use of the Applet class's inheritance from the Panel class to resize the applet based on the input values.
Parameters:
width-an integer value specifying the applet's new width.
height-an integer value specifying the applet's new height.

resize

public void resize(Dimension d)
This resize function accepts a Dimension object as its argument.
Parameters: d-a Dimension object that specifies the new size of the applet.

showStatus

public void showStatus(String msg)
showStatus
shows a status message using the applet's context.
Parameters: msg-a string containing the message to be displayed.

getImage

public Image getImage(URL url)
getImage
retrieves image information based on the URL input parameter. Note that this function returns immediately and does not retrieve the entire image. This image will not be retrieved until the Image object is actually needed.
Parameters: url-a URL object containing location information for the image to be retrieved.
Returns: An Image object containing information about the URL passed in.

getImage

public Image getImage(URL url, String name)
This getImage function accepts both the URL input parameter containing base location information as well as a String input parameter containing the filename.
Parameters:
url-a URL object containing base location information for the image to be retrieved.
name-a string object containing a filename relative to the base URL passed using the url argument.
Returns: An Image object containing information about the URL passed in.

getAudioClip

public AudioClip getAudioClip(URL url)
getAudioClip
retrieves an AudioClip based on the URL input parameter.
Parameters: url-a URL object containing location information for the clip to be retrieved.
Returns: An AudioClip object that can be played at a later time.

getAudioClip

public AudioClip getAudioClip(URL url, String name)
This getAudioClip function accepts both the URL input parameter containing base location information as well as a String input parameter containing the filename.
Parameters:
url-a URL object containing base location information for the AudioClip to be retrieved.
name-a string object containing a filename relative to the base URL passed using the url argument.
Returns: An AudioClip object that can be played at a later time.

getAppletInfo

public String getAppletInfo()
getAppletInfo
is provided for applet authors to return name, copyright, and version information for their applets. The default implementation returns null.
Returns: A String containing author, version, and copyright information (or anything else) for the applet.

getParameterInfo

public String[][] getParameterInfo()
getParameterInfo
is provided for applet authors to provide information on any parameters that the applet may take as input. Conventional return values have the following information: name, type, and comments. The default implementation returns a null String array.
Returns: A String array where each element contains, by Java conventions, three values: name, type, and comments. Each of these elements represent a parameter that the applet takes as input.

play

public void play(URL url)
play
is used to play an AudioClip at the location given by the URL input parameter.
Parameters: url-a URL object containing location information for the clip to be retrieved.

play

public void play(URL url, String name)
This play method is used to play an AudioClip given a base URL and a filename for input parameters.
Parameters:
url-a URL object containing base location information for the AudioClip to be retrieved.
name-a string object containing a filename relative to the base URL passed using the url argument.

init

public void init()
The init method is called automatically after the applet is created. This function never needs to be called directly.

start

public void start()
The start method is called automatically to start the applet after it has been initialized. This function never needs to be called directly. start is called when an applet is first displayed on a screen, or when a page is revisited within a Web browser.

stop

public void stop()
The stop method is called automatically to stop an applet from running. This function never needs to be called directly unless the applet knows that it needs to stop executing. stop is called when the Web page containing the applet is replaced by another Web page.

destroy

public void destroy()
The destroy method is called automatically when the applet's system resources are being reclaimed. This function never needs to be called directly. destroy is called after the stop method has finished.


footer nav
Use of this site is subject certain Terms & Conditions.
Copyright (c) 1996-1999 EarthWeb, Inc.. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Please read our privacy policy for details.