Java print screen program

我的未来我决定 提交于 2019-12-11 14:02:43

问题


I am trying to use Robot in Java to make an image file of a print screen. So far I have:

 Robot robot = new Robot();
 Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
 BufferedImage capture = new Robot().createScreenCapture(screenRect);
 ImageIO.write(capture, "bmp", new File("printscreen.bmp"));

But I can't seem to get it to create the file.


回答1:


s/printscreen.bmp/"printscreen.bmp"



回答2:


Not sure if .bmp files are support. Oops, they are:

System.out.println( Arrays.asList( ImageIO.getWriterFileSuffixes() ) );

You can also use the Screen Image class for some more general screen printing features.



来源:https://stackoverflow.com/questions/4318694/java-print-screen-program

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!