I am trying to insert a sleeper thread inbetween two actions in an else statement, here is my code:
} catch (InterruptedException ie)
} Could someone tell me why the background changes above the try statement are being skipped, and how to fix it, or tell me of another way to put in a time delay. Thanks.
Sleeping in the GUI event thread is literally a waste of time, and background changes don't actually happen until the next paint event is processed, and all that your sleep is accomplishing is delaying the processing of the next paint event, and the next paint event is processing both the background changes in quick succession, probably eliminating the first one, so you don't see it.
If you want to see the background change twice you would have to submit two SwingWorker tasks to execute several seconds apart.
It's a GUI. Don't think sequential programming. It's not. It's event driven.
Could someone tell me why the background changes above the try statement are being skipped, and how to fix it, or tell me of another way to put in a time delay.
How can anyone tell execution is even getting into the ELSE half of the statement or that the actions are even part of a different thread?
The 4 second sleep only has meaning if the actions are to objects in a different thread. If you take action in the current thread and then immediately sleep how will you see the effect of those actions?
Post the entire code and tell us what it is you are really trying to do.