Recommended: Sing it, brah! 5 fabulous songs for developers
JW's Top 5
Hi All,
I would like to save an (invisible) JFrame into an image file (jpeg).In other words, I only want to save the drawing to an image file without displaying it to the users.
I tried:
BufferedImage image = new BufferedImage(frame.getWidth(), frame.getHeight(),
BufferedImage.TYPE_INT_RGB);
Graphics2D graphics2D = image.createGraphics();
frame.panel.paint(graphics2D);
ImageIO.write(image,"png", new File("image.png"));
But this only works with a visible frame (frame.setVisible(true))
Any thoughts?
Thanks a lot.