The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

need help with Timer and sound

hey everyone,

can someone help me on this problem
i have a Timer and a JButton in my application, and everytime i click on the button
it will play the sound file, however everytime it play the sound, the Timer stop
and the Timer will run again after playing the sound

i want the Timer to continue running while playing the Sound
btw this is the code(for testing purpose)

Re: need help with Timer and sound

Swing operates on a single thread called the EDT, so any long processes a program has should be placed on a separate thread so it doesn't clog up the EDT. In your case, the playing of the sound clip could be clogging up the EDT so any calls by the timer will not be run until that process has ended. To overcome this you can play your sound on a seperate thread