Playing sound in a Swing application

Try out this small application with evil_laugh.wav:

import java.awt.image.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import java.awt.*;
import java.net.*;
 
public class Main extends JFrame
{
   public Main() {
      getContentPane().setLayout(new BorderLayout());
      final JLabel label = new JLabel("Sound file: ");
      final JTextField textfield = new JTextField(30);
      final JButton button = new JButton("Play");
      getContentPane().add(BorderLayout.WEST, label);
      getContentPane().add(BorderLayout.CENTER, textfield);
      getContentPane().add(BorderLayout.EAST, button);
 
      button.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent ae) {
            try {
               URL codebase = new URL("file:" + System.getProperty("user.dir") + "/");
               AudioClip audioClip = Applet.newAudioClip(new URL(codebase, textfield.getText()));
               audioClip.play();
            } catch (MalformedURLException e) {
               System.err.println(e.getMessage());
            }
         }
      });
 
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent we) {
            System.exit(1);
         }
      });      
 
      pack();
   }
 
   public static void main(String []args) throws Exception {
      Main main = new Main();
      main.show();      
   }
}