• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Image Icon Update Problem??

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ImageIO.read 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic