Here you can find the source of createMonoColoredImageIcon(final Paint paint, final int width, final int height)
Parameter | Description |
---|---|
paint | color of the image |
width | width of the image |
height | height of the image |
public static ImageIcon createMonoColoredImageIcon(final Paint paint, final int width, final int height)
//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); } }