![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e604. Getting the Current Screen Refresh Rate and Number of ColorsThis example retrieves the refresh rate (in Hz) and number of supported colors for all screens.GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); for (int i=0; i<gs.length; i++) { DisplayMode dm = gs[i].getDisplayMode(); // Get refresh rate in Hz int refreshRate = dm.getRefreshRate(); if (refreshRate == DisplayMode.REFRESH_RATE_UNKNOWN) { // Unknown rate } // Get number of colors int bitDepth = dm.getBitDepth(); if (bitDepth == DisplayMode.BIT_DEPTH_MULTI) { // Multiple bit depths are supported in this display mode } else { int numColors = (int)Math.pow(2, bitDepth); } }
e599. Centering a Frame, Window, or Dialog on the Screen e600. Getting the Number of Screens e601. Enabling Full-Screen Mode e602. Double-Buffering in Full-Screen Mode e603. Getting the Available Screen Sizes, Refresh Rates, and Number of Colors e605. Setting the Screen Size, Refresh Rate, or Number of Colors
© 2002 Addison-Wesley. |