简体   繁体   English

如何以编程方式知道系统是否处于双显示器模式?

[英]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.但是对于以双显示器模式连接的系统,需要一组不同的代码来获取完整的 180 度屏幕截图。

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 :您可以使用 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();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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