Here you can find the source of buildIcon(final String relativePath, final Class loader)
public static Icon buildIcon(final String relativePath, final Class loader)
//package com.java2s; //License from project: Open Source License import javax.swing.*; import java.net.URL; public class Main { public static Icon buildIcon(final String relativePath, final Class loader) { URL resource = loader.getResource(relativePath); if (resource != null) { return new ImageIcon(resource); } else {/*w w w . ja v a 2 s. co m*/ System.err.println("[ImageHelper] Invalid resource: " + relativePath + " Loader: " + loader.getName()); throw new IllegalArgumentException("Invalid resource"); } } }