title: Java Detecting when sound stops
body: <p>I have a sound class for my application and it plays a certain sound when I tell it too. I want to be able to detect when the sound is finished playing so I can then play a different sound without them over lapping here is my sound class:</p>
  
  <pre><code>public class Sound {
  
  public static final Sound cash = new Sound("/cash.wav");
  public static final Sound snap = new Sound("/snap.wav");
  public static final Sound disarm = new Sound("/disarm.wav");
  public static final Sound tp = new Sound("/tp.wav");
  public static final Sound select = new Sound("/selectBTN.wav");
  public static final Sound scroll = new Sound("/btn.wav");
  public static final Sound fire = new Sound("/fire2.wav");
  
  private AudioClip c;
  
  public Sound(String filename) {
      try {
          c = Applet.newAudioClip(Sound.class.getResource(filename));
  
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  
  public void play() {
      try {
          new Thread() {
              public void run() {
                  if (!title.mute) {
  
                      c.play();
                  }
              }
          }.start();
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>then to play the sound I use this line of code:</p>
  
  <pre><code>   Sound.cash.play();
  </code></pre>
  
  <p>How can I detect when the sound is finished playing</p>