Java examples for 2D Graphics:Image File
creates an image icon from the file located at the specified path
import javax.swing.ImageIcon; public class Main{ /**//from w ww. j ava2 s .c o m * creates an image icon from the file located at the specified path */ public static ImageIcon createImageIcon(String path, String description) { java.net.URL imgURL = DesktopUtils.class.getResource(path); if (imgURL != null) { return new ImageIcon(imgURL, description); } else { System.err.println("Couldn't find file: " + path); return null; } } }