Here you can find the source of createFileImageIcon(final String path)
static ImageIcon createFileImageIcon(final String path)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.net.MalformedURLException; import java.net.URL; import javax.swing.ImageIcon; public class Main { static ImageIcon createFileImageIcon(final String path) { try {/*from w ww . j a v a2 s . c o m*/ ImageIcon imageIcon; File file; URL url; file = new File(path); if (!file.exists()) throw new Error(String.format("Image \"%s\" not found.", path)); url = file.toURI().toURL(); imageIcon = new ImageIcon(url); return imageIcon; } catch (MalformedURLException e) { throw new Error(e); } } }