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

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.