Java ImageIcon createMonoColoredImageIcon(final Paint paint, final int width, final int height)

Here you can find the source of createMonoColoredImageIcon(final Paint paint, final int width, final int height)

Description

Creates a rectangular mono colored image.

License

LGPL

Parameter

Parameter Description
paint color of the image
width width of the image
height height of the image

Return

mono colored rectangular image

Declaration

public static ImageIcon createMonoColoredImageIcon(final Paint paint, final int width, final int height) 

Method Source Code


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

import java.awt.Graphics2D;

import java.awt.Paint;

import java.awt.image.BufferedImage;

import javax.swing.ImageIcon;

public class Main {
    /**//from   w w  w.  java 2s .c o m
     * Creates a rectangular mono colored image.
     *
     * @param paint color of the image
     * @param width width of the image
     * @param height height of the image
     * @return mono colored rectangular image
     */
    public static ImageIcon createMonoColoredImageIcon(final Paint paint, final int width, final int height) {
        final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR_PRE);
        final Graphics2D g = image.createGraphics();
        g.setPaint(paint);
        final int lineHeight = 4;
        g.fill3DRect(0, height / 2 - lineHeight / 2, width, lineHeight, false);
        g.dispose();
        return new ImageIcon(image);
    }
}

Related

  1. createCursor(ImageIcon cursorIcon, Point hotSpot, String name)
  2. createCursor(ImageIcon icon, Point hotspot)
  3. createDisabledImage(final ImageIcon imageIcon)
  4. createEmptyImageIcon(final int width, final int height)
  5. createFileImageIcon(final String path)
  6. createNonCachedImageIcon(File file)
  7. createOverlayIcon(Icon baseIcon, ImageIcon overlayIcon)
  8. createScaledImageIcon(byte[] albumArtBytes)
  9. CreateSizedImageIconScaledSmooth(URL filePath, int width, int height)