This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes how to change the ImageIcon of a JLabel? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to change the ImageIcon of a JLabel?" Watch "how to change the ImageIcon of a JLabel?" New topic
Author

how to change the ImageIcon of a JLabel?

Kay Tracid
Ranch Hand

Joined: Mar 06, 2002
Posts: 148
Hi,
I have a JLabel with an icon that is shown fine. Only if i try to change the icon, i get no effect. Can you help, please?
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
hi,
try to change the icon inside SwingUtilities.invokeLater() (see the API for more information.)
All Code that changes the graphic inside a GUI has to be called from the Swing thread. To be sure of that always change the gui inside SwingUtilities.invokeLater().
Chantal
Kay Tracid
Ranch Hand

Joined: Mar 06, 2002
Posts: 148
Thanks!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to change the ImageIcon of a JLabel?
 
It's not a secret anymore!