Java Export JPanel contents to a png
Posted on 2013-12-20
I have my own customized JPanel (MyJpanel extends JPanel) that has been added to a JFrame. I've been adding graphics and images to this JPanel from within its paintComponent method.
I need to export the contents of my JPanel to a png file. I know it goes something like this:
ImageIO.write(rendImage, "png", new File( "screenshot.png" ) );
...but I don't know how to get the rendImage. How do I specify the contents?