org.springframework.richclient.util
Class WindowUtils

java.lang.Object
  extended by org.springframework.richclient.util.WindowUtils

public class WindowUtils
extends Object

Utility functions for manipulating the display of windows.

Author:
Keith Donald

Method Summary
static void centerOnParent(Window window, Component parent)
          Center the window relative to it's parent.
static void centerOnParentAndSetVisible(Window window)
          Pack the window, center it relative to it's parent, and set the window visible.
static void centerOnScreen(Window window)
          Take the window and center it on the screen.
static void centerOnScreenAndSetVisible(Window window)
          Pack the window, center it on the screen, and set the window visible.
static Point getCenteringPointOnScreen(Dimension dimension)
          Return the centering point on the screen for the object with the specified dimension.
static Dimension getDimensionFromPercent(int percentWidth, int percentHeight)
          Return a Dimension whose size is defined not in terms of pixels, but in terms of a given percent of the screen's width and height.
static int getScreenHeight()
           
static Dimension getScreenSize()
          Return the system screen size.
static int getScreenWidth()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getScreenSize

public static Dimension getScreenSize()
Return the system screen size.

Returns:
The dimension of the system screen size.

getCenteringPointOnScreen

public static Point getCenteringPointOnScreen(Dimension dimension)
Return the centering point on the screen for the object with the specified dimension.

Parameters:
dimension - the dimension of an object
Returns:
The centering point on the screen for that object.

centerOnScreenAndSetVisible

public static void centerOnScreenAndSetVisible(Window window)
Pack the window, center it on the screen, and set the window visible.

Parameters:
window - the window to center and show.

centerOnScreen

public static void centerOnScreen(Window window)
Take the window and center it on the screen.

This works around a bug in setLocationRelativeTo(...): it currently does not take multiple monitors into accounts on all operating systems.

Parameters:
window - the window to center

centerOnParentAndSetVisible

public static void centerOnParentAndSetVisible(Window window)
Pack the window, center it relative to it's parent, and set the window visible.

Parameters:
window - the window to center and show.

centerOnParent

public static void centerOnParent(Window window,
                                  Component parent)
Center the window relative to it's parent. If the parent is null, or not showing, the window will be centered on the screen

Parameters:
window - the window to center
parent - the parent

getDimensionFromPercent

public static final Dimension getDimensionFromPercent(int percentWidth,
                                                      int percentHeight)
Return a Dimension whose size is defined not in terms of pixels, but in terms of a given percent of the screen's width and height.

Use to set the preferred size of a component to a certain percentage of the screen.

Parameters:
percentWidth - percentage width of the screen, in range 1..100.
percentHeight - percentage height of the screen, in range 1..100.

getScreenWidth

public static int getScreenWidth()

getScreenHeight

public static int getScreenHeight()


Copyright © 2004-2008 The Spring Framework. All Rights Reserved.