Here you can find the source of createBitmap(Icon icon)
public static BufferedImage createBitmap(Icon icon)
//package com.java2s; //License from project: LGPL import java.awt.AlphaComposite; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import javax.swing.Icon; public class Main { public static BufferedImage createBitmap(Icon icon) { BufferedImage bi = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g = bi.createGraphics(); g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); icon.paintIcon(null, g, 0, 0);/* w ww . j ava 2s . c o m*/ g.dispose(); return bi; } }