Here you can find the source of createImageIcon(String path)
Parameter | Description |
---|---|
path | The path of the image |
public static ImageIcon createImageIcon(String path)
//package com.java2s; //License from project: Open Source License import java.net.URL; import javax.swing.ImageIcon; public class Main { /**// w ww . j a v a 2 s. c o m * 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); } }