Convenience to create an Icon 16x16 - Java 2D Graphics

Java examples for 2D Graphics:Icon

Description

Convenience to create an Icon 16x16

Demo Code


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;
    }
}

Related Tutorials