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; /**/* www . jav a2 s . c om*/ BlackBoard BreadBoard Designer Written and maintained by Matthias Pueski Copyright (c) 2010-2011 Matthias Pueski This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ import java.net.URL; import javax.swing.ImageIcon; public class Main { /** * 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); // TODO : Check if that works with webstart // URL u = ClassLoader.getSystemResource(realPath);//UIUtils.class.getResource(path); if (u == null) return null; return new ImageIcon(u); } }