• Post Reply Bookmark Topic Watch Topic
  • New Topic

Label not repainting inside method.  RSS feed

 
Paul Carter
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Trying to paint 2 diferent icons in succession with a pause in between, but it only seems to repaint the label on exiting the method.

i.e. in the following code it pauses 4 seconds then changes the label to show the WARRIOR icon, and if I swap the images around only the black is shown.

Any ideas?

Thanks in advance

Paul.

final void TowerShow {
ti.ShowImage(Tower.picLabel, ti.BLACK);
Tower.picLabel.repaint();
Pause(4); //Pauses 4 Seconds - def. works
ti.ShowImage(Tower.picLabel, ti.WARRIOR);
}
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I guess you are doing this on the event dispatch thread, which is also responsible for redrawing the GUI. So as long as your method runs, the GUI cannot be redrawn.

If that's the case, you will need to execute that code on a different thread.

Moving to our Swing forum...
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!