The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.awt  [78 examples] > The Screen  [8 examples]

e603. 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 e605 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();
    }

 Related Examples
e598. Getting the Screen Size
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
e604. Getting the Current Screen Refresh Rate and Number of Colors
e605. Setting the Screen Size, Refresh Rate, or Number of Colors

See also: Colors    Components    Containers    Cursors    Drawing    Events    Focus    Frames    GridBagLayout    Images    Shapes    Simulating Events    Text   


© 2002 Addison-Wesley.