Java ImageIcon generateImageIcon(Color color, int size, Insets insets)

Here you can find the source of generateImageIcon(Color color, int size, Insets insets)

Description

generate Image Icon

License

Open Source License

Declaration

public static ImageIcon generateImageIcon(Color color, int size, Insets insets) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *                       I N T E L   C O R P O R A T I O N
 * //from  w  w w. ja  va  2  s  . com
 *  Functional Group: Fabric Viewer Application
 * 
 *  File Name: Util.java
 * 
 *  Archive Source: $Source$
 * 
 *  Archive Log: $Log$
 *  Archive Log: Revision 1.18  2015/08/18 14:28:35  jijunwan
 *  Archive Log: PR 130033 - Fix critical issues found by Klocwork or FindBugs
 *  Archive Log: - DateFormat is not thread safe. Changed to create new DateFormat to avoid sharing it among different threads
 *  Archive Log:
 *  Archive Log: Revision 1.17  2015/08/17 18:54:12  jijunwan
 *  Archive Log: PR 129983 - Need to change file header's copyright text to BSD license txt
 *  Archive Log: - changed frontend files' headers
 *  Archive Log:
 *  Archive Log: Revision 1.16  2015/07/28 18:29:10  fisherma
 *  Archive Log: PR 129219 - Admin page login dialog improvement
 *  Archive Log:
 *  Archive Log: Revision 1.15  2015/07/14 17:00:59  jijunwan
 *  Archive Log: PR 129541 - Should forbid save or deploy when there is invalid edit on management panel
 *  Archive Log: - removed unnecessary argument for warning message display
 *  Archive Log:
 *  Archive Log: Revision 1.14  2015/06/10 19:58:58  jijunwan
 *  Archive Log: PR 129120 - Some old files have no proper file header. They cannot record change logs.
 *  Archive Log: - wrote a tool to check and insert file header
 *  Archive Log: - applied on backend files
 *  Archive Log:
 * 
 *  Overview:
 * 
 *  @author: jijunwan
 * 
 ******************************************************************************/

import java.awt.Color;

import java.awt.Graphics2D;

import java.awt.Insets;

import java.awt.image.BufferedImage;

import javax.swing.ImageIcon;

public class Main {
    public static ImageIcon generateImageIcon(Color color, int size, Insets insets) {
        BufferedImage image = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2d = image.createGraphics();
        g2d.setColor(color);
        if (insets != null) {
            g2d.fillRect(insets.left, insets.top, size - insets.left - insets.right,
                    size - insets.top - insets.bottom);
        }
        g2d.dispose();
        return new ImageIcon(image);
    }
}

Related

  1. displayImage(final ImageIcon ii)
  2. drawImageBorder(Graphics g, ImageIcon img, Rectangle rect, Insets ins, boolean drawCenter)
  3. drawImageBorder(Graphics g, ImageIcon img, Rectangle rect, Insets ins, boolean drawCenter)
  4. fitIcon(ImageIcon icon, int containerWidth, int containerHeight)
  5. fitToSquare(ImageIcon icon, int newSize)
  6. getBorderedIcon(ImageIcon icon)
  7. getByteImage(ImageIcon icon)
  8. getDisabledIcon(ImageIcon icon)
  9. getHeight(ImageIcon imagen)