email me at borlaj@portlandschools.org

Loading
notes previous (10/<10) submit the dump links  
 

Sound in JFrames

 

To add sound to JFrame, keep your code about sound from here.

Now add the following imports:

            import sun.audio.*;
			import java.io.File;
            import java.applet.*;
            
And put these methods in (note comment them out when you switch it to a JApplet)
               
	public AudioClip getAudioClip(boolean nothing, String fileName)
    {
        AudioClip returnClip=null;
        File file = new File(fileName);

        try {
            returnClip = JApplet.newAudioClip(file.toURL());

        } catch (Exception e) {
            e.getMessage();
        }
        return returnClip;
    }
    public boolean getCodeBase(){
        return false;
    }