Here you can find the source of loadIcon(Class pRootClass, String strPath)
public static final ImageIcon loadIcon(Class pRootClass, String strPath)
//package com.java2s; //License from project: Open Source License import java.net.URL; import javax.swing.ImageIcon; public class Main { public static final ImageIcon loadIcon(Class pRootClass, String strPath) { URL imgURL = pRootClass.getResource(strPath); if (imgURL != null) return new ImageIcon(imgURL); else/*from w ww . j a v a 2 s.c om*/ return null; } }