Java Utililty Methods Swing Icon

List of utility methods to do Swing Icon

Description

The list of methods to do Swing Icon are organized into topic(s).

Method

IconcreateColourIcon(int colour)
create Colour Icon
BufferedImage image = new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB);
for (int x = 0; x < 16; x++) {
    for (int y = 0; y < 16; y++) {
        image.setRGB(x, y, colour);
return new ImageIcon(image);
IconcreateGrayIcon(Icon icon)
create Gray Icon
return new ImageIcon(GrayFilter.createDisabledImage(((ImageIcon) icon).getImage()));
IconcreateGrayIcon(Icon icon)
Creates a 'disabled' version of an icon.
Icon disabledIcon = null;
if (icon instanceof ImageIcon)
    disabledIcon = new ImageIcon(GrayFilter.createDisabledImage(((ImageIcon) icon).getImage()));
return (disabledIcon != null) ? disabledIcon : icon;
javax.swing.IconcreateIcon(java.awt.Component component)
create Icon
javax.swing.Icon rv;
java.awt.Dimension size = component.getPreferredSize();
if ((size.width > 0) && (size.height > 0)) {
    java.awt.image.BufferedImage image = new java.awt.image.BufferedImage(size.width, size.height,
            java.awt.image.BufferedImage.TYPE_INT_ARGB);
    java.awt.Graphics g = image.getGraphics();
    if (IS_PRINT_USED) {
        component.print(g);
...
IconcreateIcon(String resource)
create Icon
URL url = ClassLoader.getSystemResource(resource);
return new ImageIcon(url);
ImageIconcreateIcon(URL resource)
This method creates and returns an icon.
return new ImageIcon(resource);
ImageIconcreateIconFromResource(ClassLoader loader, String resourceName)
create Icon From Resource
return createIconFromResource(loader, resourceName, "");
ImageIconcreateIconFromStream(InputStream input)
create Icon From Stream
return createIconFromStream(input, "");
IconcreateTransparentIcon()
create Transparent Icon
BufferedImage emptyImage = new BufferedImage(SMALL_ICON_WIDTH, SMALL_ICON_WIDTH,
        BufferedImage.TYPE_INT_ARGB);
return new ImageIcon(emptyImage);
IconcreateTransparentIcon(final int width, final int height)
Creates a transparent icon.
return new ImageIcon(createTransparentImage(width, height));