Here you can find the source of createNonCachedImageIcon(File file)
public static ImageIcon createNonCachedImageIcon(File file)
//package com.java2s; /*//from w w w. ja va 2s . com * Copyright (C) 2006 The Concord Consortium, Inc., * 25 Love Lane, Concord, MA 01742 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * END LICENSE */ import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.ImageIcon; public class Main { /** * ImageIcon's constructors use MediaTracker to load an image, which is cached. As a result, subsequent changes on * the content of the image do not show up. This method uses ImageIO class to remove the caching effect. Caution: * You should NOT use this method to create ImageIcon's whose content will NOT change. */ public static ImageIcon createNonCachedImageIcon(File file) { try { return new ImageIcon(ImageIO.read(file)); } catch (IOException e) { e.printStackTrace(); return null; } } }