Java examples for 2D Graphics:BufferedImage Create
Creates a buffered image from an icon.
//package com.java2s; import javax.swing.*; import java.awt.*; import java.awt.image.*; public class Main { /**/* www.j a v a2 s . c o m*/ * Creates a buffered image from an icon. */ public static BufferedImage getBufferedImageFromIcon(Icon icon) { BufferedImage buffer = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); Graphics g = buffer.getGraphics(); icon.paintIcon(new JLabel(), g, 0, 0); g.dispose(); return buffer; } }