Skip to content
Snippets Groups Projects

Screenshot

The snippet can be accessed without any authentication.
Authored by wirnersv60307
Edited
screenshot.java 357 B
public static BufferedImage doScreenshot(JComponent component) {
    int width = component.getWidth();
    int height = component.getHeight();
    BufferedImage screenshot = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    Graphics2D graphics2D = screenshot.createGraphics();
    component.paint(graphics2D);
    return screenshot;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment