import java.applet.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;

public class DogButton
    extends JButton
{
    
    AudioClip clip;
    
    public DogButton(JApplet applet)
    {
	super("Dog Button");
	// Get the "code base" of the applet.
	URL codeBase = applet.getCodeBase();
	// Now load al the images using the applet itself.
        clip = applet.getAudioClip(codeBase, "bark.au");
    	Image image = applet.getImage(codeBase, "dog.gif");
    	Image rollImage = applet.getImage(codeBase, "dog-roll.gif");
    	Image pressImage = applet.getImage(codeBase, "dog-press.gif");
    	ImageIcon icon = new ImageIcon(image);
	ImageIcon rollIcon = new ImageIcon(rollImage);
	ImageIcon pressIcon = new ImageIcon(pressImage);
	setIcon(icon);
	setRolloverIcon(rollIcon);
	setPressedIcon(pressIcon);
	setVerticalTextPosition(SwingConstants.BOTTOM);
	setHorizontalTextPosition(SwingConstants.CENTER);
	addActionListener(new ActionListener()
	{
	    public void actionPerformed(ActionEvent ae)
	    {
		clip.play();
	    }
	});
    }

}
