This is how I can make a screenshot of a whole JFrame
Rectangle screenRect = cap.getBounds();
File docfile = new File("image");
BufferedImage capture = new Robot().createScreenCapture(screenRect);
ImageIO.write(capture, "png", file);
with cap
being a JFrame. But when I use a JPanel for cap
, I get a partly screenshot of my desktop, not only of the JPanel, what I actually want.