Right, here is what I want to do..
On the click of a button I want to
1) Change text diapleyd in JLabel called myLabel
2) Play some busin
3) Change text diapleyd in JLabel called myLabel
Now, here goes my ActionListener code,
Where myLabel is 'newed' and added to a JPanel which uses FlowLayout. The JButton which uses this ButtonListener also resides within the same JPanel.
Problem
Upon Clicking the button, all I get is the music and the JLabel changed to "done" on first click!!
What's wrong. My music.wav lasted 10seconds!
On the click of a button I want to
1) Change text diapleyd in JLabel called myLabel
2) Play some busin
3) Change text diapleyd in JLabel called myLabel
Now, here goes my ActionListener code,
Code:
class ButtonListener extends ActionListener
{
private JLabel myLabel;
public ButtonListener (JLabel myLabel)
{
this.myLabel= myLabel;
}
public void actionPerformed(ActionEvent e)
{
myLabel.setLabel("Playing");
myLabel.repaint();
//When button is clicked, play the music.wav file
under the audio directory
URL audioURL = new URL("file:"
+System.getProperty("user.dir") + "/audio/music.wav");
AudioClip myClip = Applet.newAudioClip(audioURL);
myClip.play();
myLabel.setLabel("done");
myLabel.repaint();
}
Where myLabel is 'newed' and added to a JPanel which uses FlowLayout. The JButton which uses this ButtonListener also resides within the same JPanel.
Problem
Upon Clicking the button, all I get is the music and the JLabel changed to "done" on first click!!
What's wrong. My music.wav lasted 10seconds!