java print screen two monitors

前端 未结 3 630
遇见更好的自我
遇见更好的自我 2021-02-13 20:03

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         


        
3条回答
  •  春和景丽
    2021-02-13 20:39

    Union together the bounds of each screen:

    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);
    

提交回复
热议问题