<p>I have a desktop application having heavyweight components (JxBrowser) in a JFrame. How can I make a snapshot from the GUI and save it to for example a png file? </p>

<p>Note: The method using Graphics2d and Component.paint()/paintAll()/print/printAll works only for lightweight components. </p>

<p>Any answers appreciated!</p>

<p><strong>EDIT</strong></p>

<p>I have already tried this:</p>

<pre><code>robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())); 
</code></pre>

<p>But I want the inner component to be captured...</p>

<p><strong>EDIT</strong></p>

<p>The situation seems to converge to this solution: if I have a bigger heavyweight component in my JFrame, so it is rendered on a JScrollPane then there exist no other method to get a snapshot of it programatically then to scroll it/screenshot it with screencapture?</p>

You mean programmatically?
What about
```
```
Point p = yourAwtComponent.getLocationOnScreen();
int w   = yourAwtComponent.getWidth();
int h   = yourAwtComponent.getHeight();

Rectangle rectangle = new Rectangle( p.x, p.y, w, h );

Image image = robot.createScreenCapture(rectangle);
```
```
And then something like this:
```
```
ImageIO.write( image, "png", file );
```
```