• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sleep before command above?  RSS feed

 
Meyer Florian
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
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!