Usman Ahmed
Usman Ahmed

Reputation: 79

saving JFrame as image file (.JPG, .PNG, .BMP etc)

There is a JFrame with JPanel DefaultTableModel with JScrollPane. How to save the entire JFrame to an image file?

Upvotes: 3

Views: 5059

Answers (1)

Juvanis
Juvanis

Reputation: 25950

ImageIO class will help you. The signature of the method you need is:

public static boolean write(RenderedImage im, String formatName, File output)

Determine image extension (.jpg, .png, .bmp etc) via formatName parameter. For more information take a look at this post:

http://www.java-tips.org/java-se-tips/java.awt/how-to-capture-screenshot.html

Upvotes: 2

Related Questions