Stop image icon from caching.

I am trying to make the imageicon on some jLabels change dynamically when the image file changes but it seems like Java is caching the images and thus it wont work. Is there a way to disable the caching?
[210 byte] By [jdk2006a] at [2007-11-27 5:39:58]
# 1
use setIcon in class JLabel
calvino_inda at 2007-7-12 15:15:54 > top of Java-index,Java Essentials,Java Programming...
# 2
You can use the ImageIO class to read a fresh copy of the image.
camickra at 2007-7-12 15:15:54 > top of Java-index,Java Essentials,Java Programming...
# 3

Is this an applet? The applet plugin itself does caching.

Otherwise, don't use the version of ImageIcon that takes a path string

as an argument, because it callsToolkit's getImage, which caches.

Instead use the ImageIcon constructor that takes an image, and use

ImageIO to read that image.

Hippolytea at 2007-7-12 15:15:54 > top of Java-index,Java Essentials,Java Programming...
# 4
But the Imageio read in a buffered image and the seticon method needs an image.
jdk2006a at 2007-7-12 15:15:54 > top of Java-index,Java Essentials,Java Programming...
# 5
> and the seticon method needs an image. No, it needs an Icon and you can use an ImageIcon.
camickra at 2007-7-12 15:15:54 > top of Java-index,Java Essentials,Java Programming...
# 6

> But the Imageio read in a buffered image and the seticon method needs an image.

Huh?

BufferedImage bi = ImageIO.read(url_or_file_etc);

Icon icon = new ImageIcon(bi);

label.setIcon(icon);

BufferedImage is a subclass of Image, natch.

Hippolytea at 2007-7-12 15:15:54 > top of Java-index,Java Essentials,Java Programming...