I have a JAVA program with JButtons on a panel.
Long story short, the program does quick calculation and then moves a graphic object. If I let the program run full speed, it makes all its moves in a few seconds and the end user can't see all the moves.
So I want to put a pause or sleep in the "loop" so it waits about 1 second between turns.
The problem I have, is that I want the end user to be able to click on other JButtons to modify the program as it runs. Since the program is running as a single thread, when i do a sleep or pause, it freezes up the whole program interface.
In Visual Basic, there is a sleep command that pauses the current thread, but the GUI still reacts to events that are triggered.
How do you do that in JAVA???
Start Free Trial