简体   繁体   English

是否可以通过Java在os x中获得已连接显示器的最大支持分辨率?

[英]Is it possible to get the maximum supported resolution of a connected display in os x from java?

Assume java 1.6 and leopard. 假设有Java 1.6和Leopard。 Ideally, it would also be nice to get a list of all supported resolutions and the current resolution. 理想情况下,获得所有支持的分辨率和当前分辨率的列表也将是一件很不错的事情。 If this isn't possible in java, is there some way to do it that could be called from java? 如果这在Java中是不可能的,是否有某种方法可以从Java中调用呢?

    GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment()
        .getScreenDevices();
    for (int i = 0; i < devices.length; i++) {
        GraphicsDevice dev = devices[i];
        System.out.println("device " + i);
        DisplayMode[] modes = dev.getDisplayModes();
        for (int j = 0; j < modes.length; j++) {
            DisplayMode m = modes[j];
            System.out.println(" " + j + ": " + m.getWidth() + " x " + m.getHeight());
        }
    }

With this code you can determine the current resolution. 使用此代码,您可以确定当前的分辨率。 On my system (SuSE linux) it does NOT output the possible resolutions. 在我的系统(SuSE linux)上,它不会输出可能的分辨率。

Seems to work an Mac and Windows. 似乎可以在Mac和Windows上使用。

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

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