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?
Asked
Active
Viewed 828 times
1 Answers
6
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.

Marcel
- 3,749
- 6
- 29
- 35
-
This works well on XP with Java 6. (changed to comment so binding isn't lost) – davenpcj Sep 27 '08 at 00:06