• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Sleep before command above?  RSS feed

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey there!
In a Class extending a JFrame, I've got a contentPane and inside a JLabel "someJLabel" set to be NOT visible. There is also a JButton on the panel and if I click the button, the following code will be executed:
someJLabel.setVisible(true);
try {
Thread.sleep(1000);
}
catch(InterruptedException ie) {
}
Does anyone know why the Label becomes visible AFTER the 1000 milliseconds I waited because of Thread.sleep(1000)? Does anyone know a solution?
Thanks in advance
Florian Meyer
 
author and iconoclast
Posts: 24203
40
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't sleep on the event handling thread without preventing further event handling or painting; if the event handler is blocked, the setVisible() call won't have any effect. Tell us what you're actually trying to accomplish here, and we can probably tell you how to do it.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!