简体   繁体   中英

How to know programmatically if the system is in dual monitor mode?

My system monitoring app takes screenshot every five minutes it runs in a system. But for a system connected in dual monitor mode needs a different set of codes to take the complete 180 degree screenshot.

Is there a way to know if the system is working in dual monitor mode by some means(system property)?

you can use GraphicsEnvironment https://docs.oracle.com/javase/7/docs/api/java/awt/GraphicsEnvironment.html :

private String getMonitorSizes() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[]    gs = ge.getScreenDevices();
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < gs.length; i++) {
        DisplayMode dm = gs[i].getDisplayMode();
        sb.append(i + ", width: " + dm.getWidth() + ", height: " + dm.getHeight() + "\n");
    }
    return sb.toString();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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