Having a weird problem. I'm trying to have a series of events:
1) gui event happens
2) 3 second pause
3) another gui event happens.
However, for some reason, the first gui event happens after the delay, dispite clearly being stated before the delay! Another interesting factor here is that non-gui elements in the same location are executed in the expected order (see the code below).
System.out.println("before delay"); //line executed before delay
image.setVisible(false); //line executed AFTER delay
repaint();
try{
TimeUnit.SECONDS.sleep(3);
}
catch(InterruptedException error)
{
}
image.setVisible(true); //executed after delay
System.out.println("after delay"); //executed after delay