Example usage for java.awt DisplayMode getHeight

List of usage examples for java.awt DisplayMode getHeight

Introduction

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

Prototype

public int getHeight() 

Source Link

Document

Returns the height of the display, in pixels.

Usage

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./*from w ww .j av a2s . c  om*/
 * <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  v a  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);
        }
    }

}