I am trying to display an image whose contents are changed after some time. I am displaying it in JLabel
, but the problem is when I reload this image it's not changing in JLabel
as seems JLabel#setIcon(new ImageIcon("myImagePath.png"));
caches image in the memory and when I changes that it look for the name and did not load it from harddisk.
Even I use two Images to flip whose data contents are changed? Any one know how to fix that? But every time loading image with different name works fine?
Lines creating problem: E.g. My image changed on button click event
jlabel.setIcon("d:\\img.png");
jlabel.repaint();