ImageUtils.java 613 Bytes
package osp.ui;

import javax.swing.ImageIcon;

public class ImageUtils {

	/**
	 * Creates and returns an ImageIcon from the image on the specified path, or
	 * null if the path was invalid.
	 * 
	 * @param path
	 *            Path of the image.
	 * @return The corresponding ImageIcon or null if there is no image with
	 *         this path.
	 */
	public static ImageIcon createImageIcon(String path) {
		java.net.URL imgURL = ImageUtils.class.getResource(path);
		if (imgURL != null) {
			return new ImageIcon(imgURL);
		} else {
			System.err.println("Couldn't find file: " + path);
			return null;
		}
	}

}