Getting the Current Screen Refresh Rate and Number of Colors : GraphicsEnvironment « 2D Graphics « Java Tutorial






import java.awt.DisplayMode;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;

public class Main {
  public static void main(String[] argv) throws Exception {

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gs = ge.getScreenDevices();

    for (int i = 0; i < gs.length; i++) {
      DisplayMode dm = gs[i].getDisplayMode();

       int refreshRate = dm.getRefreshRate();
      if (refreshRate == DisplayMode.REFRESH_RATE_UNKNOWN) {
        System.out.println("Unknown rate"); 
      }

      int bitDepth = dm.getBitDepth();
      int numColors = (int) Math.pow(2, bitDepth);
    }
  }
}








16.52.GraphicsEnvironment
16.52.1.List all fonts system installed
16.52.2.Different buffer capabilities for each GraphicsConfiguration on each GraphicsDevice
16.52.3.Get all fonts
16.52.4.Getting Screen Sizes
16.52.5.Getting Refresh Rates
16.52.6.Getting Number of Colors
16.52.7.Getting the Current Screen Refresh Rate and Number of Colors
16.52.8.Getting the Font Faces for a Font Family
16.52.9.Get the available font family names
16.52.10.Getting Amount of Free Accelerated Image Memory
16.52.11.Create an image that does not support transparency from GraphicsConfiguration
16.52.12.Create an image that supports transparent pixels from GraphicsConfiguration
16.52.13.Create an image that supports arbitrary levels of transparency from GraphicsConfiguration
16.52.14.Create buffered images that are compatible with the screen
16.52.15.Retrieve and print the graphic device information
16.52.16.Generates a table of all available display modes, enters full-screen mode and allows you to change the display mode
16.52.17.Setting the Screen Size, Refresh Rate, or Number of Colors
16.52.18.If more than one screen is available, gets the size of each screen
16.52.19.Computes the maximum bounds of the current screen device. If this method is called on JDK 1.4, Xinerama-aware results are returned.
16.52.20.Computes the center point of the current screen device.