Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Time delay in Java

957909Aug 24 2012 — edited Sep 16 2012
I 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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 14 2012
Added on Aug 24 2012
4 comments
262 views