import java.io.*;
import javax.swing.*;
import java.awt.event.*;
import javax.sound.sampled.*;

public class soundApp extends JFrame
{
    JButton button;                 
    Clip clip;

    public soundApp()
    {
        setDefaultCloseOperation(EXIT_ON_CLOSE); 
        setSize(300,300);

        File file = new File("tada.wav");  

        try
        {
            AudioInputStream audiosource = AudioSystem.getAudioInputStream(file);
            DataLine.Info info = 
                new DataLine.Info(Clip.class, audiosource.getFormat());
            clip = (Clip)AudioSystem.getLine(info);   
            clip.open(audiosource);
        }
        catch(UnsupportedAudioFileException e){}
        catch(LineUnavailableException e){}
        catch(IOException e){}

        button = new JButton("Play sound");
        button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e){
            if(e.getActionCommand().equals("Play sound"))
                clip.loop(clip.LOOP_CONTINUOUSLY);}});

        Container contentpane = getContentPane();
        contentpane.add(button);
        setVisible(true);
  }

  public static void main(String[] args)
  {
      soundApp soundapp = new soundApp();
  }
}
