Here you can find the source of createImage(JPanel panel)
Parameter | Description |
---|---|
panel | a parameter |
public static BufferedImage createImage(JPanel panel)
//package com.java2s; //License from project: Creative Commons License import java.awt.Graphics2D; import java.awt.image.BufferedImage; import javax.swing.JPanel; public class Main { /**//w ww . j ava 2 s . co m * Crea una imagen del contenido de un JPanel * @param panel * @return */ public static BufferedImage createImage(JPanel panel) { int w = panel.getWidth(); int h = panel.getHeight(); BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics2D g = bi.createGraphics(); panel.paint(g); return bi; } }