Make sound play in a java application
Hi, I am developing a GUI that demonstrates the use of many of the JFrame, JPanel, etc components.
One part of the program I want to be a music player, where you press a button to open a file chooser, choose a song, and it plays. Here is the code for the buttonlistener:
My problem is that the music doesn't play. I've tried a variety of techniques that were supposed to make sound play in a java application, but none of them have worked.
private class ButtonListener implements ActionListener
public void actionPerformed (ActionEvent event)
JFileChooser chooser = new JFileChooser();
int status = chooser.showOpenDialog(null);
if (status != JFileChooser.APPROVE_OPTION)
song1.setText("No File Yet Chosen");
File file = chooser.getSelectedFile();
The program compiles, but when I click on the button, so sound comes out (even if I choose a .wav file from the file chooser).