Here you can find the source of getImageIcon(String path, String description)
Parameter | Description |
---|---|
path | can't be <code>null</code> or whitespace, use forward slashes even on Windows systems |
description | a parameter |
static ImageIcon getImageIcon(String path, String description)
//package com.java2s; //License from project: Open Source License import java.net.URL; import javax.swing.ImageIcon; public class Main { /**/*from w w w.j av a 2s.c o m*/ * Returns an ImageIcon, or null if the path was invalid. * * @param path can't be <code>null</code> or whitespace, use * forward slashes even on Windows systems * @param description * @return see above */ static ImageIcon getImageIcon(String path, String description) { // Check path is valid if (path == null || path.trim().length() == 0) { throw new IllegalArgumentException("Invalid file path: " + path); } URL imgURL = ClassLoader.getSystemResource(path); if (imgURL != null) { return new ImageIcon(imgURL, description); } throw new IllegalArgumentException("Couldn't find file: " + path); } }