Skip to Main Content

Java SE (Java Platform, Standard Edition)

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!

Update jLabel in between Thread.sleep()'s

843807Mar 7 2010 — edited Mar 7 2010
I have multiple Thread.sleep()'s in my code under a jButton actionevent evt.

In between these, I need to be able to update a jLabel, but for some reason it waits until the last thread.sleep() before it updates the jLabel.

Any ideas why?
private void jButtonActionPerformed(java.awt.event.ActionEvent evt) {
   try {

      Thread.sleep(1000);

      jLabel.setText("Change Text To This");

      Thread.sleep(1000);

   } catch (InterruptedException ex) {}
}
So rather than waiting 1000ms, then update label, then wait another 1000ms, it just waits 2000ms, then updates the label

Please help!

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 4 2010
Added on Mar 7 2010
8 comments
466 views