Here you can find the source of getIconImage(String path)
public static ImageIcon getIconImage(String path)
//package com.java2s; /**/*w ww . ja v a 2 s . co m*/ * Copyright 2013 by PanicLauncher and Contributors * * This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. * To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/. */ import java.io.File; import java.net.URL; import javax.swing.ImageIcon; public class Main { public static ImageIcon getIconImage(String path) { URL url = System.class.getResource(path); if (url == null) { System.err.println("Unable to load image: " + path); } ImageIcon icon = new ImageIcon(url); return icon; } public static ImageIcon getIconImage(File file) { if (!file.exists()) { System.err.println("Unable to load image: " + file.getAbsolutePath()); } ImageIcon icon = new ImageIcon(file.getAbsolutePath()); return icon; } }