Here you can find the source of getIcon(String _package, String iconName)
Parameter | Description |
---|---|
_package | a parameter |
iconName | a parameter |
public static ImageIcon getIcon(String _package, String iconName)
//package com.java2s; //License from project: Open Source License import java.net.URL; import javax.swing.ImageIcon; public class Main { /**//from ww w.j a v a 2 s .co m * Gets the icon in the specified package with the specified name. * * A package might be UIUtils.X16, UIUtils.X32, etc * * @param _package * @param iconName * @return The icon, or null if the icon doesn't exist */ public static ImageIcon getIcon(String _package, String iconName) { if (!_package.endsWith("/")) { _package += "/"; } return getIcon(_package + iconName); } /** * Gets the icon at the specified path * * @param path The path of the icon * @return The icon, or null if the icon file doesn't exist */ public static ImageIcon getIcon(String path) { return createImageIcon(path); } /** * Create an ImageIcon from the image at the specified path * * @param path The path of the image * @return The image icon, or null if the image doesn't exist */ public static ImageIcon createImageIcon(String path) { URL u = Thread.currentThread().getContextClassLoader().getResource(path); //URL u = ClassLoader.getSystemResource(path);//UIUtils.class.getResource(path); if (u == null) { return null; } return new ImageIcon(u); } }