Getting the Available Screen Sizes, Refresh Rates, and Number of Colors
This example demonstrates how to retrieve all available combinations
of screen size, refresh rate, or number of colors for the default
screen device. See also Setting the Screen Size, Refresh Rate, or Number of Colors.
// Determine if the display mode can be changed
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gs = ge.getDefaultScreenDevice();
DisplayMode[] dmodes = gs.getDisplayModes();
for (int i=0; i<dmodes.length; i++) {
int screenWidth = dmodes[i].getWidth();
int screenHeight = dmodes[i].getHeight();
int bitDepth = dmodes[i].getBitDepth();
int refreshRate = dmodes[i].getRefreshRate();
}
Post a comment