This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes Image Icon Update Problem?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Image Icon Update Problem??" Watch "Image Icon Update Problem??" New topic

Image Icon Update Problem??

Lee Siong Tai

Joined: Dec 20, 2009
Posts: 1
We encounter problem when using ImageIcon, anyone can help?
In JFrame1, we use ImageIcon to show an image (says, C:\abc.jpg with an apple) on JButton
It shows Apple on the Jbutton.

We then update abc.jpg. (says, copy C:\def.jpg with an orange to C:\abc.jpg)
So, we check in Windows, both abc.jpg and def.jpg are orange now.

But when we load again JFrame1, the image on JButton is still show apple.
We expect it is an orange.

So, we close the apps and start again.
Now, it shows orange.

We use to read the image to BufferedImage and use it in construct ImageIcon.

It seems that ImageIcon cache the image and does not reload it.
How can we clear the cache and force ImageIcon to load the latest image?

Thank you.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Image Icon Update Problem??
jQuery in Action, 3rd edition