Java ImageIcon createEmptyImageIcon(final int width, final int height)

Here you can find the source of createEmptyImageIcon(final int width, final int height)

Description

Creates an empty image.

License

LGPL

Parameter

Parameter Description
width width of image
height height of image

Return

empty image

Declaration

public static ImageIcon createEmptyImageIcon(final int width, final int height) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.awt.Graphics2D;

import java.awt.image.BufferedImage;

import javax.swing.ImageIcon;

public class Main {
    /**//from  w ww.ja v  a2 s .c om
     * Creates an empty image.
     *
     * @param width width of image
     * @param height height of image
     * @return empty image
     */
    public static ImageIcon createEmptyImageIcon(final int width, final int height) {
        final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR_PRE);
        final Graphics2D g = image.createGraphics();
        g.dispose();
        return new ImageIcon(image);
    }
}

Related

  1. createBase64StringFromImage(ImageIcon image)
  2. createColorImageIcon(int w, int h, int c)
  3. createCursor(ImageIcon cursorIcon, Point hotSpot, String name)
  4. createCursor(ImageIcon icon, Point hotspot)
  5. createDisabledImage(final ImageIcon imageIcon)
  6. createFileImageIcon(final String path)
  7. createMonoColoredImageIcon(final Paint paint, final int width, final int height)
  8. createNonCachedImageIcon(File file)
  9. createOverlayIcon(Icon baseIcon, ImageIcon overlayIcon)