Example usage for java.awt DisplayMode REFRESH_RATE_UNKNOWN

List of usage examples for java.awt DisplayMode REFRESH_RATE_UNKNOWN

Introduction

In this page you can find the example usage for java.awt DisplayMode REFRESH_RATE_UNKNOWN.

Prototype

int REFRESH_RATE_UNKNOWN

To view the source code for java.awt DisplayMode REFRESH_RATE_UNKNOWN.

Click Source Link

Document

Value of the refresh rate if not known.

Usage

From source file:Main.java

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");
        }//from   w ww .  ja v  a 2s. co  m

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

From source file:DisplayModeModel.java

public Object getValueAt(int rowIndex, int colIndex) {
    DisplayMode dm = modes[rowIndex];
    switch (colIndex) {
    case DisplayModeTest.INDEX_WIDTH:
        return Integer.toString(dm.getWidth());
    case DisplayModeTest.INDEX_HEIGHT:
        return Integer.toString(dm.getHeight());
    case DisplayModeTest.INDEX_BITDEPTH: {
        int bitDepth = dm.getBitDepth();
        String ret;//from  w w w  . j  a  v a  2  s. c  om
        if (bitDepth == DisplayMode.BIT_DEPTH_MULTI) {
            ret = "Multi";
        } else {
            ret = Integer.toString(bitDepth);
        }
        return ret;
    }
    case DisplayModeTest.INDEX_REFRESHRATE: {
        int refreshRate = dm.getRefreshRate();
        String ret;
        if (refreshRate == DisplayMode.REFRESH_RATE_UNKNOWN) {
            ret = "Unknown";
        } else {
            ret = Integer.toString(refreshRate);
        }
        return ret;
    }
    }
    throw new ArrayIndexOutOfBoundsException("Invalid column value");
}

From source file:DisplayModeModel.java

public void setDMLabel(DisplayMode newMode) {
    int bitDepth = newMode.getBitDepth();
    int refreshRate = newMode.getRefreshRate();
    String bd, rr;//from  w  w  w.  j a va2s . c om
    if (bitDepth == DisplayMode.BIT_DEPTH_MULTI) {
        bd = "Multi";
    } else {
        bd = Integer.toString(bitDepth);
    }
    if (refreshRate == DisplayMode.REFRESH_RATE_UNKNOWN) {
        rr = "Unknown";
    } else {
        rr = Integer.toString(refreshRate);
    }
    currentDM.setText(COLUMN_NAMES[INDEX_WIDTH] + ": " + newMode.getWidth() + " " + COLUMN_NAMES[INDEX_HEIGHT]
            + ": " + newMode.getHeight() + " " + COLUMN_NAMES[INDEX_BITDEPTH] + ": " + bd + " "
            + COLUMN_NAMES[INDEX_REFRESHRATE] + ": " + rr);
}

From source file:Filter3dTest.java

/**
 * Determines if two display modes "match". Two display modes match if they
 * have the same resolution, bit depth, and refresh rate. The bit depth is
 * ignored if one of the modes has a bit depth of
 * DisplayMode.BIT_DEPTH_MULTI. Likewise, the refresh rate is ignored if one
 * of the modes has a refresh rate of DisplayMode.REFRESH_RATE_UNKNOWN.
 *///from w  ww .ja  v  a 2  s .  c  o  m
public boolean displayModesMatch(DisplayMode mode1, DisplayMode mode2)

{
    if (mode1.getWidth() != mode2.getWidth() || mode1.getHeight() != mode2.getHeight()) {
        return false;
    }

    if (mode1.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI && mode2.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI
            && mode1.getBitDepth() != mode2.getBitDepth()) {
        return false;
    }

    if (mode1.getRefreshRate() != DisplayMode.REFRESH_RATE_UNKNOWN
            && mode2.getRefreshRate() != DisplayMode.REFRESH_RATE_UNKNOWN
            && mode1.getRefreshRate() != mode2.getRefreshRate()) {
        return false;
    }

    return true;
}