Here you can find the source of getImageIcon(final String iconName)
public static ImageIcon getImageIcon(final String iconName)
//package com.java2s; import java.awt.Image; import java.awt.Toolkit; import java.io.IOException; import java.net.URL; import javax.imageio.ImageIO; import javax.swing.ImageIcon; public class Main { public static ImageIcon getImageIcon(final String iconName) { return new ImageIcon(getImage(iconName)); }//from w ww .j a v a 2 s . c o m public static ImageIcon getImageIcon(final String iconName, final ClassLoader classLoader) { final Image image = getImage(iconName, classLoader); if (image == null) { return null; } return new ImageIcon(image); } public static Image getImage(final String imageName, final ClassLoader classLoader) { final URL url = classLoader.getResource("bitmaps/" + imageName); if (url == null) { return null; } try { return ImageIO.read(url); } catch (final IOException e) { e.printStackTrace(); } return null; } public static Image getImage(final String imageName) { return Toolkit.getDefaultToolkit().getImage("bitmaps/" + imageName); } }