aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Saving JPanel as image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Saving JPanel as image" Watch "Saving JPanel as image" New topic
Author

Saving JPanel as image

Jeff Storey
Ranch Hand

Joined: Oct 09, 2006
Posts: 118
I'm trying to save the contents of a JPanel as an image. It is pretty straightforward to write the graphics to a BufferedImage, however, the problem is when all of the JPanel is not actually displayed on the screen (in this particular case, it's not in a scrollpane, but I cannot change this). The getGraphics method only returns what is visible - is there any way to get the non-visible portion also?

Thank you,
Jeff
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
couple of ideas here

http://forum.java.sun.com/thread.jspa?threadID=604040
Jeff Storey
Ranch Hand

Joined: Oct 09, 2006
Posts: 118
Thanks - That's where I got my start from. The main difficulty is still when the JPanel area is not visible and not in a scrollpane - thought there might be a different way.
Jeff Storey
Ranch Hand

Joined: Oct 09, 2006
Posts: 118
I think I just have to get it into a scroll pane.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Saving JPanel as image