简体   繁体   中英

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

Assume java 1.6 and 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?

    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.

Seems to work an Mac and Windows.

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