Here you can find the source of getImage(JComponent component)
Parameter | Description |
---|---|
component | a parameter |
public static BufferedImage getImage(JComponent component)
//package com.java2s; //License from project: Apache License import javax.swing.*; import java.awt.*; import java.awt.image.*; public class Main { /**// w ww . j a v a 2 s .c om * draw the component as an image * * @param component * @return */ public static BufferedImage getImage(JComponent component) { BufferedImage ret = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_RGB); Graphics g = ret.getGraphics(); component.paint(g); g.dispose(); return ret; } }