Example usage for java.awt DisplayMode getWidth

List of usage examples for java.awt DisplayMode getWidth

Introduction

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

Prototype

public int getWidth() 

Source Link

Document

Returns the width of the display, in pixels.

Usage

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 w  w. ja v a  2s.c  om
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;
}

From source file:Filter3dTest.java

/**
 * Enters full screen mode and changes the display mode. If the specified
 * display mode is null or not compatible with this device, or if the
 * display mode cannot be changed on this system, the current display mode
 * is used.// w w  w.j  ava  2 s .  com
 * <p>
 * The display uses a BufferStrategy with 2 buffers.
 */
public void setFullScreen(DisplayMode displayMode) {
    final JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setUndecorated(true);
    frame.setIgnoreRepaint(true);
    frame.setResizable(false);

    device.setFullScreenWindow(frame);

    if (displayMode != null && device.isDisplayChangeSupported()) {
        try {
            device.setDisplayMode(displayMode);
        } catch (IllegalArgumentException ex) {
        }
        // fix for mac os x
        frame.setSize(displayMode.getWidth(), displayMode.getHeight());
    }
    // avoid potential deadlock in 1.4.1_02
    try {
        EventQueue.invokeAndWait(new Runnable() {
            public void run() {
                frame.createBufferStrategy(2);
            }
        });
    } catch (InterruptedException ex) {
        // ignore
    } catch (InvocationTargetException ex) {
        // ignore
    }

}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java

public void checkForInitialLoadScreenSizes(final FormControl control, final JSplitPane verticalMain,
        final String verticalMainName, final JSplitPane verticalSub, final String verticalSubName,
        final JSplitPane horizontalMain, final String horizontalMainName, final JSplitPane horizontalSub,
        final String horizontalSubName) {
    if ((control.getWidth() == -1) && (control.getHeight() == -1) && (control.getLeft() == -1)
            && (control.getTop() == -1)) {
        final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        final GraphicsDevice[] gs = ge.getScreenDevices();
        if (gs.length > 0) {
            final DisplayMode dm = gs[0].getDisplayMode();
            final int screenWidth = dm.getWidth() - 20;
            final int screenHeight = dm.getHeight() - 50;
            // Set form bounds
            control.setTop(10);//ww w .j  a  va  2 s  .c  o  m
            control.setLeft(10);
            control.setWidth(screenWidth);
            control.setHeight(screenHeight);
            control.resizeScreen();
            // Set divider positions
            int dividerPosition = 175;
            verticalMain.setDividerLocation(dividerPosition);
            control.setExtra(verticalMainName, dividerPosition);
            dividerPosition = screenHeight / 3;
            verticalSub.setDividerLocation(dividerPosition);
            control.setExtra(verticalSubName, dividerPosition);
            dividerPosition = screenWidth / 3;
            horizontalMain.setDividerLocation(dividerPosition);
            control.setExtra(horizontalMainName, dividerPosition);
            horizontalSub.setDividerLocation(dividerPosition);
            control.setExtra(horizontalSubName, dividerPosition);
        }
    }

}