FileDocCategorySizeDatePackage
AppletMethods.javaAPI DocExample1632Sat Mar 13 22:10:38 GMT 1999None

AppletMethods

public class AppletMethods extends Applet
AppletMethods -- show stop/start and AudioClip methods

Fields Summary
AudioClip
snd
AudioClip object, used to load and play a sound file.
Constructors Summary
public AppletMethods()
Yes, applets can have constructors!


	      
	  
		System.out.println("In Appletmethods::<init> No Arg form");
	
Methods Summary
public voiddestroy()
Called from the Browser (when the applet is being un-cached?). Not actually used here, but the println will show when it's called.

		System.out.println("In AppletMethods.destroy()");
	
public java.lang.StringgetParameter(java.lang.String p, java.lang.String def)
An alternate form of getParameter that lets you provide a default value, since this is so common.

		return getParameter(p)==null?def:getParameter(p);
	
public voidinit()
Initialize the sound file object and the GUI.

		System.out.println("In AppletMethods.init()");
		try {
			snd = getAudioClip(new URL(getCodeBase(), "laugh.au"));
		} catch (MalformedURLException e) {
			showStatus(e.toString());
		}
		setSize(200,100);	// take the place of a GUI
	
public voidpaint(java.awt.Graphics g)

		g.drawString("Welcome to Java", 50, 50);
	
public voidstart()
Called from the Browser when the page is ready to go.

		System.out.println("In AppletMethods.start()");
		if (snd != null)
			snd.play();	// loop() to be obnoxious...
	
public voidstop()
Called from the Browser when the page is being vacated.

		System.out.println("In AppletMethods.stop()");
		if (snd != null)
			snd.stop();	// stop play() or loop()