Java Image Create createImage(JPanel panel)

Here you can find the source of createImage(JPanel panel)

Description

Crea una imagen del contenido de un JPanel

License

Creative Commons License

Parameter

Parameter Description
panel a parameter

Declaration

public static BufferedImage createImage(JPanel panel) 

Method Source Code

//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;
    }
}

Related

  1. createImage(byte[] data)
  2. createImage(Component comp, Icon icon)
  3. createImage(Icon icon)
  4. createImage(String str)
  5. createImage(URL url, String description, boolean checkPresence)
  6. createImageCopy(Image image)
  7. createImageFromBase64String(String s)