Java Image getPanelImage(JPanel p)

Here you can find the source of getPanelImage(JPanel p)

Description

I think it's more expensive to layout 1000 charts than it is to layout 1000 already rendered (fixed) images.

License

Open Source License

Declaration

public static Image getPanelImage(JPanel p) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.*;
import java.awt.*;

import java.awt.image.BufferedImage;

public class Main {
    /**//from  w  w w .ja v  a 2  s.  c  om
     * I think it's more expensive to layout 1000 charts than it is to layout 1000 
     * already rendered (fixed) images. 
     */
    public static Image getPanelImage(JPanel p) {
        JFrame frame;
        frame = new JFrame();
        frame.setContentPane(p);
        frame.pack();

        Dimension size = p.getPreferredSize();
        BufferedImage image = new BufferedImage((int) size.width,
                (int) size.height, BufferedImage.TYPE_INT_RGB);
        p.paint(image.createGraphics());

        return (image);
    }
}

Related

  1. getInputStreamFromImage(Image imagen, String format)
  2. getLogoImage()
  3. getManagedImage(Component source, String file, float tint, Color solid)
  4. getNewImageFileChooser()
  5. getOpenSwingImage(String name)
  6. getScreenShareImage()
  7. getShieldImage()
  8. getWindowImage(Window window)
  9. imageOf(Action action)