I am using netbeans 6.8 .If a sound file is playing, a button on the jframe wont work while the sound file is playing. The user should still be able to press the button while it is playing.
I tried to find it but the codes are very complex.
Use Main implements runnable{}
Multithread this problem.
Asked
Active
Viewed 146 times
0
-
2What havwe you've tried so far? Give some code please. – Thomas Jungblut Jul 27 '11 at 15:24
3 Answers
5
It sounds like you are playing a sound on the Event despatch thread. Any long running tasks should not be run on this since, as you've seen, it'll lock the gui.

Jim
- 22,354
- 6
- 52
- 80
2
Try SwingWorker. There are Tutorial and StackOverflow question.

Community
- 1
- 1

user802421
- 7,465
- 5
- 40
- 63
1
You can either implement thread yourself or use higher level tools like
- Executors.newSingleThreadExecutor().execute(command)
- java.util.Timer: new Timer().schedule(task, 0)
- SwingWorker (asm mentioned by @user802421
Here is how you can run task asynchronously using your own thread:
new Thread() {
public void run() {
// write here your code
}
}.start();

AlexR
- 114,158
- 16
- 130
- 208