Java examples for 2D Graphics:Icon
Convenience to create an Icon 16x16
import java.awt.Image; import java.net.URISyntaxException; import javax.swing.Icon; import javax.swing.ImageIcon; public class Main{ /**/*from w w w .j ava2s .com*/ * Convenience to create an Icon 16x16 */ public static Icon createIcon16x16(String path) { return createImageIcon(path, 16, 16); } public static ImageIcon createImageIcon(String path, int w, int h) { ImageIcon imageIcon = null; try { imageIcon = ImageCache.getInstance().getImageIcon( null, ImageHelper.class.getClassLoader().getResource(path) .toURI(), w, h); } catch (URISyntaxException ignore) { imageIcon = null; } return imageIcon; } }