Java Utililty Methods ImageIcon

List of utility methods to do ImageIcon

Description

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

Method

BufferedImageabsoluteDifferenceImage(ImageIcon icon1, ImageIcon icon2, double scale)
Generate the absolute difference image between two images
return plotRGB(absoluteDifferenceImage(grabRGB(icon1), grabRGB(icon2), scale), icon1.getIconWidth(),
        icon1.getIconHeight());
ImageIconcomponentToImageIcon(Component c, String description, boolean paintBorder)
create an ImageIcon delegate of a component
return componentToImageIcon(c, description, paintBorder, 1, Image.SCALE_SMOOTH);
BufferedImageconvert(ImageIcon icon)
Convert the Input ImageIcon into a BufferedImage with type TYPE_INT_ARGB
if (icon == null) {
    throw new IllegalArgumentException("ImageIcon is null");
BufferedImage buffered = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(),
        BufferedImage.TYPE_INT_ARGB);
Graphics2D g = buffered.createGraphics();
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION,
...
StringcreateBase64StringFromImage(ImageIcon image)
create Base String From Image
return null;
ImageIconcreateColorImageIcon(int w, int h, int c)
Create a colored image icon.
BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
        img.setRGB(j, i, c);
return new ImageIcon(img);
CursorcreateCursor(ImageIcon cursorIcon, Point hotSpot, String name)
create Cursor
return createCursor(cursorIcon.getImage(), hotSpot, name);
CursorcreateCursor(ImageIcon icon, Point hotspot)
Creates a cursor from an ImageIcon
if (icon == null) {
    return null;
return createCursor(icon.getImage(), hotspot, icon.getDescription());
ImageIconcreateDisabledImage(final ImageIcon imageIcon)
Creates a new grayed image based on the image passed in.
final GrayFilter filter = new GrayFilter(true, 75);
final ImageProducer imageSource = imageIcon.getImage().getSource();
final ImageProducer imageProducer = new FilteredImageSource(imageSource, filter);
final Image grayImage = Toolkit.getDefaultToolkit().createImage(imageProducer);
return new ImageIcon(grayImage);
ImageIconcreateEmptyImageIcon(final int width, final int height)
Creates an empty image.
final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR_PRE);
final Graphics2D g = image.createGraphics();
g.dispose();
return new ImageIcon(image);
ImageIconcreateFileImageIcon(final String path)
create File Image Icon
try {
    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();
...