Here you can find the source of makeEmptyIcon(Dimension size, Color color)
public static ImageIcon makeEmptyIcon(Dimension size, Color color)
//package com.java2s; //License from project: Open Source License import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.image.BufferedImage; import javax.swing.ImageIcon; public class Main { public static ImageIcon makeEmptyIcon(Dimension size, Color color) { ImageIcon result = null;/* w w w .jav a 2s. c o m*/ BufferedImage bufferedImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB); Graphics graphics = bufferedImage.getGraphics(); graphics.setColor(color); graphics.fillRect(0, 0, size.width, size.height); result = new ImageIcon(bufferedImage); return result; } }