This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Saving runtime Swing  UI as image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Saving runtime Swing  UI as image" Watch "Saving runtime Swing  UI as image" New topic

Saving runtime Swing UI as image

padma patil
Ranch Hand

Joined: Nov 06, 2001
Posts: 41
I have JTabbedPane which has 2 tabs. First tab component has one labels and JTabel and second tab components has 2 Jtables. I wanted to store the runtime Frame as a image when save button is clicked (Similar to file save option). I saw on many tutorial they have icons of runtime Frames. How can I achive this?
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

There are other ways, but the simplest is to use the Robot class to get a screen capture and use the new ImageIO classes to save the image.


Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Joel Cochran
Ranch Hand

Joined: Mar 23, 2001
Posts: 301
This may be overly simplistic, but if you just want a .jpg of a screen shot and don't need it generated programmatically... on a Windows machine with the screen active, press "alt-Prt Scr" and a copy of the active window will be saved as an image to your clipboard. Then you can simply paste it where ever you want it.

Wait a minute, I'm trying to think of something clever to say...<p>Joel
I agree. Here's the link:
subject: Saving runtime Swing UI as image
It's not a secret anymore!