ImageIcon不会更新具有相同URL的新图像

我想使用JLabel(Icon)来显示来自我网站的图片( http://sofzh.miximages.com/java/test.jpg )。 我有一个新的JLabel和ImageIcon刷新按钮(为了获得最新的图像)程序运行成功…但是当我上传新图像以覆盖旧图像时( http://xxx.xxx。 xxx.xxx/java_pic/test.jpg ),我按下刷新按钮……什么都没发生! 我重启我的程序……现在出现了新图像……为什么? 当我再次创建ImageIcon时,它不应该从网站重新加载图像吗?

public void refresh(){ URL iconUri = null; iconUri = new URL("http://sofzh.miximages.com/java/test.jpg"); ImageIcon imageIcon = new ImageIcon(iconUri); JLabel imageLabel = new JLabel(imageIcon); frame.add(imageLabel); ... ... } 

当我点击刷新按钮时,它会调用refresh()…为什么? 谢谢!

图像被缓存。 刷新清除缓存:

 imageIcon.getImage().flush();