本文介绍了java打印屏幕两台显示器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用打印屏幕图像区域来获得2台显示器,但仅适用于一台显示器。您能建议我如何获得图2显示器吗?
I'm trying to use print screen image area to get 2 monitors, but only works for one monitor. Can you advise me how to get figure 2 monitors?
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"));
推荐答案
结合每个屏幕的边界:
Rectangle screenRect = new Rectangle(0, 0, 0, 0);
for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) {
screenRect = screenRect.union(gd.getDefaultConfiguration().getBounds());
}
BufferedImage capture = new Robot().createScreenCapture(screenRect);
这篇关于java打印屏幕两台显示器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!