Hi

I have a problem about saving myPanel (extends Jpanel) graphic object to jpeg.
I is very strange, because on the screen every thing looks ok, and when I save
the graphics object to jpeg the saved image contains the picture of other controls
which are not belongs to that panel but exists on the same internalframe, usually the button what is starting the saving procedure in the top left corner

and if the panel is on a scrollpane, the picture contains the panel's drwaings twice or more? usually with fragments of the panel's picture?

If I execure the saving procedure from the constructor of the window (internalframe)
the active control is not appears on the saved image,
When I am using a panel in the scrollpane, when the panel has the same size as the scrollpane, so the scrollbars are not visible, then the saved picture doesn't contains fragments !

Does anybody have any idea about to save always the same picture from a panel
what I can see? (jdk 1.4 and 1.5 too)

Thank you very much in advance !

used code to save image:
---------
public void saveComponent(genPanel c,String filename)
{
int w = c.getWidth();
int h = c.getHeight();

BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = bi.createGraphics();
g2.clearRect(0, 0, w, h );
c.paint(g2);

try
{
ImageIO.write(bi, "jpg", new File(filename+".jpg"));
}
catch(IOException ioe)
{
System.err.println("write: " + ioe.getMessage());
}
g2.dispose();
}
--------------