Java The Complete Reference, Seventh Edition

(Greg DeLong) #1

Chapter 21: The Applet Class 635


The AudioClip Interface


TheAudioClipinterface defines these methods:play( )(play a clip from the beginning),
stop( )(stop playing the clip), andloop( )(play the loop continuously). After you have
loaded an audio clip usinggetAudioClip( ), you can use these methods to play it.

The AppletStub Interface


TheAppletStubinterface provides the means by which an applet and the browser (or applet
viewer) communicate. Your code will not typically implement this interface.

Method Description
Applet getApplet(StringappletName) Returns the applet specified byappletNameif it is within
the current applet context. Other wise,nullis returned.
Enumeration<Applet> getApplets( ) Returns an enumeration that contains all of the applets
within the current applet context.
AudioClip getAudioClip(URLurl) Returns anAudioClipobject that encapsulates the audio
clip found at the location specified byurl.
Image getImage(URLurl) Returns anImageobject that encapsulates the image
found at the location specified byurl.
InputStream getStream(Stringkey) Returns the stream linked tokey.Keys are linked to
streams by using thesetStream( )method. Anull
reference is returned if no stream is linked tokey.
Iterator<String> getStreamKeys( ) Returns an iterator for the keys associated with the
invoking object. The keys are linked to streams. See
getStream( )andsetStream( ).
void setStream(Stringkey,
InputStreamstrm)

Links the stream specified bystrmto the key passed inkey.
Thekeyis deleted from the invoking object ifstrmisnull.
void showDocument(URLurl) Brings the document at theURLspecified byurlinto view.
This method may not be supported by applet viewers.
void showDocument(URLurl,
Stringwhere)

Brings the document at theURLspecified byurlinto view.
This method may not be supported by applet viewers. The
placement of the document is specified bywhereas
described in the text.
void showStatus(Stringstr) Displaysstrin the status window.

TABLE 21-2 The Methods Defined by theAppletContextInter face
Free download pdf