Screen dump of JPanel to Image

I'm working on an extensive error dialog which will send all relevant information to a support apparatus. This includes collecting the stack-trace received from the exception, java console log and a screen dump of the underlying JPanel.

The dialog is a modal dialog residing on top of the JPanel in question. I can retreive the parent panel's Graphics object and need to print the JPanel with all it's children to an Image object.

This should be possible, but how?

Another thing, is the java console available from the client code? The code runs as an applet on Windows clients.

[620 byte] By [OysteinA] at [2007-9-30 3:55:56]
# 1
I've never tried this, but the idea I have is to create a BufferedImage, and getGraphics() of the BufferedImage. Now call paint() of the JPanel and pass it the graphics object. Maybe you also have to pre-obtain the height/width of the JPanel for the size of the Image.
stoopidboi at 2007-6-29 17:21:22 > top of Java-index,Archived Forums,Java Programming...
# 2
The search facility is down right now but I have a class that I think might help. Search the forum using "+camickr +screenimage" and you should find my thread once the search facility is back up.
camickr at 2007-6-29 17:21:22 > top of Java-index,Archived Forums,Java Programming...
# 3
Thanx a lot you guys. This was very helpful. Our framework uses nothing but swing components, so the repaint of the components in a buffered image worked fine.;o)
OysteinA at 2007-6-29 17:21:22 > top of Java-index,Archived Forums,Java Programming...