Example usage for java.awt Window getY

List of usage examples for java.awt Window getY

Introduction

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

Prototype

public int getY() 

Source Link

Document

Returns the current y coordinate of the components origin.

Usage

From source file:Main.java

/**
 * @param owner// w w w .  jav  a  2s.  co m
 * @param newConfigDialog
 */
public static void centerRelative(java.awt.Window main, java.awt.Window child) {
    java.awt.Dimension dim = main.getSize();
    Point _loc = center(dim, child);
    // Move the window
    _loc.translate(main.getX(), main.getY());
    child.setLocation(_loc);
}

From source file:Main.java

public static Point getPointForCentering(Dialog dialog, Window parent) {
    Dimension size = dialog.getSize();
    Dimension parentSize = parent.getSize();
    int centerX = (int) ((parentSize.getWidth() - size.getWidth()) / 2 + parent.getX());
    int centerY = (int) ((parentSize.getHeight() - size.getHeight()) / 2 + parent.getY());
    return new Point(centerX, centerY);
}

From source file:Main.java

/**
 * A version of setLocationRelativeTo() that takes the maximum window bounds into account
 * (taskbar)./*from   w  w  w . j  a va  2 s.co m*/
 */
public static void setLocationRelativeTo(Window window, Component component) {
    window.setLocationRelativeTo(component);
    Point screenLocation = getCurrentScreenLocation(window);
    if (window.getX() < screenLocation.x)
        window.setLocation(screenLocation.x, window.getY());
    if (window.getY() < screenLocation.y)
        window.setLocation(window.getX(), screenLocation.y);
}