Example usage for java.awt Window getHeight

List of usage examples for java.awt Window getHeight

Introduction

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

Prototype

public int getHeight() 

Source Link

Document

Returns the current height of this component.

Usage

From source file:au.org.ala.delta.util.Utils.java

public static void centreWindow(Window c, JFrame frame) {
    Dimension app = frame.getSize();
    int x = frame.getX() + (app.width - c.getWidth()) / 2;
    int y = frame.getY() + (app.height - c.getHeight()) / 3;
    if (y < frame.getY()) {
        y = frame.getY();//  w ww .j a  v  a2s  .c  o m
    }
    c.setLocation(x, y);
}

From source file:Filter3dTest.java

/**
 * Returns the height of the window currently used in full screen mode.
 * Returns 0 if the device is not in full screen mode.
 *//*from   w  ww .  j a  v a2s .c  o m*/
public int getHeight() {
    Window window = device.getFullScreenWindow();
    if (window != null) {
        return window.getHeight();
    } else {
        return 0;
    }
}

From source file:net.pms.newgui.components.WindowProperties.java

/**
 * Creates a new instance using the specified parameters.
 *
 * @param window the {@link Window} whose properties to keep track of.
 * @param standardSize the standard size of {@code window}.
 * @param mimimumSize the minimum size of {@code window}.
 * @param windowConfiguration the {@link WindowPropertiesConfiguration}
 *            instance for reading and writing the window properties.
 *///from  w ww . j av a  2  s  .co m
public WindowProperties(@Nonnull Window window, @Nullable Dimension standardSize,
        @Nullable Dimension mimimumSize, @Nullable WindowPropertiesConfiguration windowConfiguration) {
    if (window == null) {
        throw new IllegalArgumentException("window cannot be null");
    }
    this.window = window;
    this.minimumSize = mimimumSize;
    if (mimimumSize != null) {
        window.setMinimumSize(mimimumSize);
    }
    this.windowConfiguration = windowConfiguration;
    if (windowConfiguration != null) {
        getConfiguration();
        GraphicsConfiguration windowGraphicsConfiguration = window.getGraphicsConfiguration();
        if (windowBounds != null && effectiveScreenBounds != null && graphicsDevice != null
                && graphicsDevice.equals(windowGraphicsConfiguration.getDevice().getIDstring())
                && screenBounds != null && screenBounds.equals(windowGraphicsConfiguration.getBounds())) {
            setWindowBounds();
        } else {
            Rectangle screen = effectiveScreenBounds != null ? effectiveScreenBounds
                    : windowGraphicsConfiguration.getBounds();
            if (standardSize != null && screen.width >= standardSize.width
                    && screen.height >= standardSize.height) {
                window.setSize(standardSize);
            } else if (mimimumSize != null && (window.getWidth() < mimimumSize.width
                    || window.getHeight() < mimimumSize.getHeight())) {
                window.setSize(mimimumSize);
            }
            window.setLocationByPlatform(true);
        }
        if (window instanceof Frame) {
            // Set maximized state
            int maximizedState = windowState & Frame.MAXIMIZED_BOTH;
            if (maximizedState != 0) {
                ((Frame) window).setExtendedState(((Frame) window).getExtendedState() | maximizedState);
            }
        }
    }
    window.addWindowListener(this);
    window.addComponentListener(this);
}

From source file:net.team2xh.crt.gui.util.GUIToolkit.java

/**
 * Centers a frame on screen/*from   ww w .  ja  va2s  . c  o m*/
 *
 * @param frame Frame to center
 */
public static void centerFrame(java.awt.Window frame) {
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((screen.width - frame.getWidth()) / 2, (screen.height - frame.getHeight()) / 2);
}

From source file:org.eclipse.wb.internal.swing.utils.SwingImageUtils.java

static Image createOSXImage(Window window, Image windowImage) throws Exception {
    // draw decorations manually, because it becomes slow if using SWT shell to capture decorations. 
    int width = Math.max(1, window.getWidth());
    int height = Math.max(1, window.getHeight());
    Image fullImage = new Image(null, width, height);
    try {//from  w w  w.  jav  a2  s.  com
        GC gc = new GC(fullImage);
        //
        Insets windowInsets = getWindowInsets(window);
        int offsetY = windowInsets.top;
        int offsetX = windowInsets.left;
        // draw caption background
        {
            Image image = Activator.getImage("decorations/osx/background.png");
            int imageWidth = image.getBounds().width;
            int x = 0;
            while (x < width) {
                gc.drawImage(image, x, 0);
                x += imageWidth;
            }
        }
        // draw left corner
        {
            Image image = Activator.getImage("decorations/osx/background-left.png");
            gc.drawImage(image, 0, 0);
        }
        // draw right corner
        {
            Image image = Activator.getImage("decorations/osx/background-right.png");
            gc.drawImage(image, width - image.getBounds().width, 0);
        }
        // draw close button
        {
            Image image = Activator.getImage("decorations/osx/button-close-icon.png");
            gc.drawImage(image, 8, 3);
        }
        // draw minimize button
        {
            Image image = Activator.getImage("decorations/osx/button-minimize-icon.png");
            gc.drawImage(image, 29, 3);
        }
        // draw contents button
        {
            Image image = Activator.getImage("decorations/osx/button-contents-icon.png");
            gc.drawImage(image, 50, 3);
        }
        // draw title
        {
            String windowTitle = getWindowTitle(window);
            if (!StringUtils.isEmpty(windowTitle)) {
                gc.setClipping(70, 0, width - 80, offsetY);
                gc.setForeground(IColorConstants.titleForeground);
                org.eclipse.swt.graphics.Point titleExtent = gc.stringExtent(windowTitle);
                gc.drawString(windowTitle, width / 2 - titleExtent.x / 2, offsetY / 2 - titleExtent.y / 2,
                        true);
                gc.setClipping((org.eclipse.swt.graphics.Rectangle) null);
            }
        }
        // draw SWING contents
        try {
            gc.drawImage(windowImage, offsetX, offsetY, width - offsetX * 2, height - offsetY - offsetX,
                    offsetX, offsetY, width - offsetX * 2, height - offsetY - offsetX);
        } finally {
            gc.dispose();
        }
    } finally {
        windowImage.dispose();
    }
    return fullImage;
}

From source file:org.isatools.isacreatorconfigurator.configui.FieldInterface.java

private void showPopupInCenter(Window container) {
    Container parent = main;//from   w w w  .  j a  va  2  s  . c om
    Point parentLocation = parent.getLocationOnScreen();

    Dimension parentSize = parent.getSize();

    int calcedXLoc = (parentLocation.x) + ((parentSize.width) / 2) - (container.getWidth() / 2);
    int calcedYLoc = (parentLocation.y) + ((parentSize.height) / 2) - (container.getHeight() / 2);

    container.setVisible(true);
    container.setLocation(calcedXLoc, calcedYLoc);
    container.toFront();
    container.requestFocusInWindow();
}

From source file:org.notebook.gui.widget.GuiUtils.java

/**
 * Sets location of a window centered in main screen device. Window must
 * have size different of (0,0)/*from w w  w. j a v a  2 s.  c  om*/
 * 
 * @param window
 */
public static void setLocation(Window window) {
    window.setLocation(mainDeviceBounds.width / 2 - window.getWidth() / 2,
            mainDeviceBounds.height / 2 - window.getHeight() / 2);
}

From source file:tkwatch.Utilities.java

/**
 * Centers a frame on the screen; from Murach and Steelman, <i>Murach's Java
 * SE 6</i>, p. 487./*from w  w w  .j a v  a  2  s. com*/
 * 
 * @param window
 *            The window to center.
 */
public static final void centerWindow(final Window window) {
    final Toolkit toolkit = Toolkit.getDefaultToolkit();
    final Dimension dimension = toolkit.getScreenSize();
    window.setLocation((dimension.width - window.getWidth()) / 2, (dimension.height - window.getHeight()) / 2);
}