FileDocCategorySizeDatePackage
PictButton.javaAPI DocExample1856Tue May 30 21:25:26 BST 2000None

PictButton

public class PictButton extends JApplet implements ActionListener

Fields Summary
AppletSoundList
soundList
String
wavFile
AudioClip
onceClip
JButton
Play
protected String
rocket
ImageIcon
pb_Icon
Constructors Summary
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent event)

        //PLAY BUTTON
        Object source = event.getSource();
        if (source == Play) {
                //Try to get the AudioClip.
                onceClip = soundList.getClip(wavFile);
                onceClip.play();     //Play it once.
                showStatus("Playing sound " + wavFile + ".");
            if (onceClip == null) {
                showStatus("Sound " + wavFile + " not loaded yet.");
            }
            return;
        }


    
protected java.net.URLgetURL(java.lang.String filename)

		URL codeBase = getCodeBase();
		URL url = null;

		try {
                        url = new URL(codeBase, filename);
                    } catch (java.net.MalformedURLException e) {
                        System.err.println("Couldn't create image: badly specified URL");
                        return null;
                    }
                System.out.println("url "+url);
                    return url;
         
public voidinit()

	
	   

		URL pict_button_URL = getURL(rocket);
	        pb_Icon = new ImageIcon(pict_button_URL);
		Play = new JButton(pb_Icon);
		Play.addActionListener(this);
		JPanel controlPanel = new JPanel();
		controlPanel.add(Play);
		getContentPane().add(controlPanel);

                startLoadingSounds();	
       
voidstartLoadingSounds()

        //Start asynchronous sound loading.
        soundList = new AppletSoundList(this, getCodeBase());
        soundList.startLoading(wavFile);