Java Icon createColorIcon(Color color)

Here you can find the source of createColorIcon(Color color)

Description

Creates the color icon.

License

Open Source License

Parameter

Parameter Description
color the color

Return

the image icon

Declaration

public static ImageIcon createColorIcon(Color color) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;

public class Main {
    /**//from w ww .j  a  v  a2s .c o  m
     * Creates the color icon.
     *
     * @param color the color
     * @return the image icon
     */
    public static ImageIcon createColorIcon(Color color) {
        BufferedImage buffImage = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
        Graphics g = buffImage.getGraphics();
        g.setColor(color);
        g.fillRect(0, 0, 16, 16);
        g.setColor(Color.black);
        g.drawRect(0, 0, 15, 15);
        return new ImageIcon(buffImage);
    }
}

Related

  1. createColorIcon(final int width, final int height, final Color color)
  2. createHistImage(JComponent c, Icon hd, File dir, Color bgColor, String fname)
  3. createRotatedImage(Component c, Icon icon, double rotatedAngle)
  4. extractIconImage(Component component, Icon icon)