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

时间:2012-02-20 12:27:46

标签: java swing jframe screenshot

JFrame JPanel DefaultTableModel JScrollPane。如何将整个JFrame保存到图像文件?

1 个答案:

答案 0 :(得分:2)

ImageIO课程会帮助你。您需要的方法的签名是:

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

通过formatName参数确定图片扩展名(。jpg,.png,.bmp等)。有关更多信息,请查看此帖:

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