Java Code Examples for java.awt.DisplayMode#getHeight()

The following examples show how to use java.awt.DisplayMode#getHeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Win32GraphicsDevice.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
protected synchronized DisplayMode getMatchingDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        return null;
    }
    DisplayMode[] modes = getDisplayModes();
    for (DisplayMode mode : modes) {
        if (dm.equals(mode) ||
            (dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN &&
             dm.getWidth() == mode.getWidth() &&
             dm.getHeight() == mode.getHeight() &&
             dm.getBitDepth() == mode.getBitDepth()))
        {
            return mode;
        }
    }
    return null;
}
 
Example 2
Source File: X11GraphicsDevice.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private synchronized DisplayMode getMatchingDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        return null;
    }
    DisplayMode[] modes = getDisplayModes();
    for (DisplayMode mode : modes) {
        if (dm.equals(mode) ||
            (dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN &&
             dm.getWidth() == mode.getWidth() &&
             dm.getHeight() == mode.getHeight() &&
             dm.getBitDepth() == mode.getBitDepth()))
        {
            return mode;
        }
    }
    return null;
}
 
Example 3
Source File: Win32GraphicsDevice.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected synchronized DisplayMode getMatchingDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        return null;
    }
    DisplayMode[] modes = getDisplayModes();
    for (DisplayMode mode : modes) {
        if (dm.equals(mode) ||
            (dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN &&
             dm.getWidth() == mode.getWidth() &&
             dm.getHeight() == mode.getHeight() &&
             dm.getBitDepth() == mode.getBitDepth()))
        {
            return mode;
        }
    }
    return null;
}
 
Example 4
Source File: Win32GraphicsDevice.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
protected synchronized DisplayMode getMatchingDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        return null;
    }
    DisplayMode[] modes = getDisplayModes();
    for (DisplayMode mode : modes) {
        if (dm.equals(mode) ||
            (dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN &&
             dm.getWidth() == mode.getWidth() &&
             dm.getHeight() == mode.getHeight() &&
             dm.getBitDepth() == mode.getBitDepth()))
        {
            return mode;
        }
    }
    return null;
}
 
Example 5
Source File: X11GraphicsDevice.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private synchronized DisplayMode getMatchingDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        return null;
    }
    DisplayMode[] modes = getDisplayModes();
    for (DisplayMode mode : modes) {
        if (dm.equals(mode) ||
            (dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN &&
             dm.getWidth() == mode.getWidth() &&
             dm.getHeight() == mode.getHeight() &&
             dm.getBitDepth() == mode.getBitDepth()))
        {
            return mode;
        }
    }
    return null;
}
 
Example 6
Source File: X11GraphicsDevice.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private synchronized DisplayMode getMatchingDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        return null;
    }
    DisplayMode[] modes = getDisplayModes();
    for (DisplayMode mode : modes) {
        if (dm.equals(mode) ||
            (dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN &&
             dm.getWidth() == mode.getWidth() &&
             dm.getHeight() == mode.getHeight() &&
             dm.getBitDepth() == mode.getBitDepth()))
        {
            return mode;
        }
    }
    return null;
}
 
Example 7
Source File: X11GraphicsDevice.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private synchronized DisplayMode getMatchingDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        return null;
    }
    DisplayMode[] modes = getDisplayModes();
    for (DisplayMode mode : modes) {
        if (dm.equals(mode) ||
            (dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN &&
             dm.getWidth() == mode.getWidth() &&
             dm.getHeight() == mode.getHeight() &&
             dm.getBitDepth() == mode.getBitDepth()))
        {
            return mode;
        }
    }
    return null;
}
 
Example 8
Source File: NonExistentDisplayModeTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static DisplayMode deriveDepth(DisplayMode dm) {
    int depth;
    if (dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI) {
        depth = 77;
    } else {
        depth = DisplayMode.BIT_DEPTH_MULTI;
    }
    return new DisplayMode(dm.getWidth(), dm.getHeight(),
                           depth, dm.getRefreshRate());
}
 
Example 9
Source File: FullScreenInsets.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static void testWindowBounds(final DisplayMode dm, final Window w) {
    if (w.getWidth() != dm.getWidth() || w.getHeight() != dm.getHeight()) {
        System.err.println(" Wrong window bounds:" +
                           " Expected: width = " + dm.getWidth()
                           + ", height = " + dm.getHeight() + " Actual: "
                           + w.getSize());
        passed = false;
    }
}
 
Example 10
Source File: FullScreenInsets.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static void testWindowBounds(final DisplayMode dm, final Window w) {
    if (w.getWidth() != dm.getWidth() || w.getHeight() != dm.getHeight()) {
        System.err.println(" Wrong window bounds:" +
                           " Expected: width = " + dm.getWidth()
                           + ", height = " + dm.getHeight() + " Actual: "
                           + w.getSize());
        passed = false;
    }
}
 
Example 11
Source File: AltTabCrashTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private DisplayMode findDisplayMode() {
    GraphicsDevice gd = getGraphicsConfiguration().getDevice();
    DisplayMode dms[] = gd.getDisplayModes();
    DisplayMode currentDM = gd.getDisplayMode();
    for (DisplayMode dm : dms) {
        if (dm.getBitDepth() > 8 &&
            dm.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI &&
            dm.getBitDepth() != currentDM.getBitDepth() &&
            dm.getWidth() == currentDM.getWidth() &&
            dm.getHeight() == currentDM.getHeight())
        {
            // found a mode which has the same dimensions but different
            // depth
            return dm;
        }
        if (dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI &&
            (dm.getWidth() != currentDM.getWidth() ||
             dm.getHeight() != currentDM.getHeight()))
        {
            // found a mode which has the same depth but different
            // dimensions
            return dm;
        }
    }

    return null;
}
 
Example 12
Source File: FullScreenInsets.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void testWindowBounds(final DisplayMode dm, final Window w) {
    if (w.getWidth() != dm.getWidth() || w.getHeight() != dm.getHeight()) {
        System.err.println(" Wrong window bounds:" +
                           " Expected: width = " + dm.getWidth()
                           + ", height = " + dm.getHeight() + " Actual: "
                           + w.getSize());
        passed = false;
    }
}
 
Example 13
Source File: FullScreenInsets.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void testWindowBounds(final DisplayMode dm, final Window w) {
    if (w.getWidth() != dm.getWidth() || w.getHeight() != dm.getHeight()) {
        System.err.println(" Wrong window bounds:" +
                           " Expected: width = " + dm.getWidth()
                           + ", height = " + dm.getHeight() + " Actual: "
                           + w.getSize());
        passed = false;
    }
}
 
Example 14
Source File: AltTabCrashTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private DisplayMode findDisplayMode() {
    GraphicsDevice gd = getGraphicsConfiguration().getDevice();
    DisplayMode dms[] = gd.getDisplayModes();
    DisplayMode currentDM = gd.getDisplayMode();
    for (DisplayMode dm : dms) {
        if (dm.getBitDepth() > 8 &&
            dm.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI &&
            dm.getBitDepth() != currentDM.getBitDepth() &&
            dm.getWidth() == currentDM.getWidth() &&
            dm.getHeight() == currentDM.getHeight())
        {
            // found a mode which has the same dimensions but different
            // depth
            return dm;
        }
        if (dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI &&
            (dm.getWidth() != currentDM.getWidth() ||
             dm.getHeight() != currentDM.getHeight()))
        {
            // found a mode which has the same depth but different
            // dimensions
            return dm;
        }
    }

    return null;
}
 
Example 15
Source File: AltTabCrashTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private DisplayMode findDisplayMode() {
    GraphicsDevice gd = getGraphicsConfiguration().getDevice();
    DisplayMode dms[] = gd.getDisplayModes();
    DisplayMode currentDM = gd.getDisplayMode();
    for (DisplayMode dm : dms) {
        if (dm.getBitDepth() > 8 &&
            dm.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI &&
            dm.getBitDepth() != currentDM.getBitDepth() &&
            dm.getWidth() == currentDM.getWidth() &&
            dm.getHeight() == currentDM.getHeight())
        {
            // found a mode which has the same dimensions but different
            // depth
            return dm;
        }
        if (dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI &&
            (dm.getWidth() != currentDM.getWidth() ||
             dm.getHeight() != currentDM.getHeight()))
        {
            // found a mode which has the same depth but different
            // dimensions
            return dm;
        }
    }

    return null;
}
 
Example 16
Source File: AltTabCrashTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private DisplayMode findDisplayMode() {
    GraphicsDevice gd = getGraphicsConfiguration().getDevice();
    DisplayMode dms[] = gd.getDisplayModes();
    DisplayMode currentDM = gd.getDisplayMode();
    for (DisplayMode dm : dms) {
        if (dm.getBitDepth() > 8 &&
            dm.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI &&
            dm.getBitDepth() != currentDM.getBitDepth() &&
            dm.getWidth() == currentDM.getWidth() &&
            dm.getHeight() == currentDM.getHeight())
        {
            // found a mode which has the same dimensions but different
            // depth
            return dm;
        }
        if (dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI &&
            (dm.getWidth() != currentDM.getWidth() ||
             dm.getHeight() != currentDM.getHeight()))
        {
            // found a mode which has the same depth but different
            // dimensions
            return dm;
        }
    }

    return null;
}
 
Example 17
Source File: FullScreenInsets.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static void testWindowBounds(final DisplayMode dm, final Window w) {
    if (w.getWidth() != dm.getWidth() || w.getHeight() != dm.getHeight()) {
        System.err.println(" Wrong window bounds:" +
                           " Expected: width = " + dm.getWidth()
                           + ", height = " + dm.getHeight() + " Actual: "
                           + w.getSize());
        passed = false;
    }
}
 
Example 18
Source File: CheckDisplayModes.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
static void checkDisplayMode(DisplayMode displayMode) {
    if (displayMode == null || displayMode.getWidth() <= 1 || displayMode.getHeight() <= 1) {
        throw new RuntimeException("invalid display mode");
    }
}
 
Example 19
Source File: NonExistentDisplayModeTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private static DisplayMode deriveSize(DisplayMode dm) {
    int w = dm.getWidth() / 7;
    int h = dm.getHeight() / 3;
    return new DisplayMode(w, h, dm.getBitDepth(), dm.getRefreshRate());
}
 
Example 20
Source File: AwtUtils.java    From uracer-kotd with Apache License 2.0 4 votes vote down vote up
public static int getCenteredYOnDisplay (int height) {
	DisplayMode mode = getNativeDisplayMode();
	return (mode.getHeight() - height) / 2;
}