List of usage examples for java.awt Window getBounds
public Rectangle getBounds()
From source file:org.intermine.common.swing.WindowUtils.java
/** * Centre the window <code>win</code> over the window <code>parent</code>. * /*from w w w . j a v a 2 s . c o m*/ * @param win The Window to position. * @param parent The reference Window. */ public static void centreOverWindow(Window win, Window parent) { Rectangle parentBounds = parent.getBounds(); Dimension windowSize = win.getSize(); int x = (parentBounds.width - windowSize.width) / 2; int y = (parentBounds.height - windowSize.height) / 2; x = Math.max(0, x + parentBounds.x); y = Math.max(0, y + parentBounds.y); win.setLocation(x, y); }