soundFile = f;
// prepare a dialog to display while playing
JOptionPane pane = new JOptionPane ("Playing " + f.getName(),
JOptionPane.PLAIN_MESSAGE);
playingDialog = pane.createDialog (null, "Application Sound");
playingDialog.pack();
// get and play sound
Line.Info linfo = new Line.Info (Clip.class);
Line line = AudioSystem.getLine (linfo);
clip = (Clip) line;
clip.addLineListener (this);
AudioInputStream ais = AudioSystem.getAudioInputStream(soundFile);
clip.open (ais);
clip.start();