# com.bea.ide.util.swing
WindowUtil Class

public class WindowUtil
extends `Object`

Utilities for placing and examining windows. This class should be used for placing and centering documents it is able to handle adjustment and centering on multiple monitor systems.

Hierarchy
  `Object`
  `WindowUtil`

## Constructor Summary

WindowUtil()

## Method Summary

`public static void` | `centerOnScreen`(`Window` window, `Point` p) Centers the given window on the screen that contains the point p.
`public static void` | `centerOnWindow`(`Window` window, `Container` parent) Centers the given window on the screen within the parent container.
`public static void` | `centerOnWindow`(`Window` window, `Container` parent, boolean doNotCover) Centers the given window on the screen within the parent container.
`public static `GraphicsConfiguration`` | `getGCForPoint`(`Point` p) Returns the default graphics configurtaion for the screen that contains the point p, or the nearest screen to the point.
`public static `Rectangle`` | `getScreenBounds`(`Rectangle` r) Returns a rectangle representing the boundaries of the screens containing the given rectangle.

Methods from class `java.lang.`Object``
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Detail

### WindowUtil

    public WindowUtil()

## Method Detail

### centerOnScreen(Window, Point) Method

    public static void centerOnScreen(Window window,
                                      Point p)

Centers the given window on the screen that contains the point p.

#### Parameters

window
  Window to center

p
  The point to use for determining the screen, if this value is null, the default screen will be used

### centerOnWindow(Window, Container) Method

    public static void centerOnWindow(Window window,
                                      Container parent)

Centers the given window on the screen within the parent container. This method will automatically adjust the windows position so that it has at least 50 pixels on any side between it and the edge of the screen boundary. The screen boundary is determined by calling `WindowUtil.getScreenBounds(Rectangle)``` using the root window of the parent container as the rectangle.

#### Parameters

window
  The window to center

parent
  The container to center the window within/below

### centerOnWindow(Window, Container, boolean) Method

    public static void centerOnWindow(Window window,
                                      Container parent,
                                      boolean doNotCover)

Centers the given window on the screen within the parent container. This method will automatically adjust the windows position so that it has at least 50 pixels on any side between it and the edge of the screen boundary. The screen boundary is determined by calling `WindowUtil.getScreenBounds(Rectangle)``` using the root window of the parent container as the rectangle. The doNotCover parameter is used to tell the method to position the window BELOW the parent rather than centered vertically within the parent.

#### Parameters

window
  The window to center

parent
  The container to center the window within/below

doNotCover
  Whether to center the window withing the parent or below the parent

### getGCForPoint(Point) Method

    public static GraphicsConfiguration getGCForPoint(Point p)

Returns the default graphics configurtaion for the screen that contains the point p, or the nearest screen to the point.

#### Parameters

p
  The point to find the graphics configuration for

#### Returns

GraphicsConfiguration object containing or nearest to p. In the event of a tie, for nearest, there is no specific algorithm to determine the winner.

Related Topics

``GraphicsConfiguration``

### getScreenBounds(Rectangle) Method

    public static Rectangle getScreenBounds(Rectangle r)

Returns a rectangle representing the boundaries of the screens containing the given rectangle. if the rectangle doesn't span any screens, the bounds will simply be the bounds of the screen containing the rectangle. If the rectangle spans screens, the bounds will be that union of all screens that the given rectangle intersects.

#### Parameters

r
  Rectangle to find the enclosing screen boundaries for

#### Returns

Rectangle representing the screen boundaries relevant to the given rectangle