简体   繁体   English

将JFrame保存为图像文件(.JPG,.PNG,.BMP等)

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

There is a JFrame with JPanel DefaultTableModel with JScrollPane . 有一个带有JScrollPane JPanel DefaultTableModelJFrame How to save the entire JFrame to an image file? 如何将整个JFrame保存到图像文件?

ImageIO class will help you. ImageIO类将帮助您。 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. 通过formatName参数确定图像扩展名(.jpg,.png,.bmp等) For more information take a look at this post: 有关更多信息,请查看此帖子:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM