Here you can find the source of getImageIcon(String path)
public static ImageIcon getImageIcon(String path)
//package com.java2s; import java.net.*; import javax.swing.*; public class Main { /**************************************************************************** * getImageIcon./*from w w w . j a v a 2s . c o m*/ ****************************************************************************/ public static ImageIcon getImageIcon(String path) { try { Object o = new Object(); Class c = o.getClass(); URL url = c.getResource("/" + path); return new ImageIcon(url); } catch (Exception e) { } try { return new ImageIcon(path); } catch (Exception e) { } return new ImageIcon(); } }