I have a method that updates part of the user interface. After this method is called I want the entire program to sleep for say 1 second. I do not want to run any code during this time, just simply pause the entire execution. What would be the best way of achieving this?
My reason is this, I am updating the GUI quite a bit and I want the user to see the change before the next change is made.
If you want the updates to be spaced out, you’ve better of using something like a
javax.swing.Timer. This will allow to schedule regular updates without causing the UI to look like it’s crashed/hung.This example will update the UI every 250 milli seconds
You can also have a look at How can I make a clock tick? which demonstrates the same idea