Time delay in Java
957909Aug 24 2012 — edited Sep 16 2012I am trying to insert a sleeper thread inbetween two actions in an else statement, here is my code:
else{
current.setBackground(Color.red);
last.setBackground(Color.red);
try {
Thread.sleep(4000);
} catch (InterruptedException ie)
{
System.out.println(ie.getMessage());
}
finally {
last.flipBack();
current.flipBack();
last.setEnabled(true);
current.setEnabled(true);
current.setBackground(null);
last.setBackground(null);
last=null;
}
}
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.