img=new ImageIcon("E:/tmp/tmp.jpg").getImage();
这时显示是正确的图片,
但当我改变了图片文件的内容(图片确实改变了),
重新调用该方法时(程序一直运行),图片显示没有变化。
PS:img=new ImageIcon(bt).getImage();//bt 为字节数组,
   当把图片文件字节流处理到数组中,图片显示可以改变。
求问 ImageIcon(string)为什么出现这样的问题,内部是如何实现的。

解决方案 »

  1.   

         * If the image data contained in the specified file changes,
         * the <code>Image</code> object returned from this method may
         * still contain stale information which was loaded from the
         * file after a prior call.
         * Previously loaded image data can be manually discarded by
         * calling the {@link Image#flush flush} method on the
         * returned <code>Image</code>.
    找到了,可以调用image.flush()来清除掉data,使得能够reload.