com.saic.isd.awt
Class WindowUtil

java.lang.Object
  extended bycom.saic.isd.awt.WindowUtil

public final class WindowUtil
extends java.lang.Object

Provides helper methods for Windows.

Typical Usage: Because this only contains static methods, it is used when needed, where needed.

Primary Life Cycle: None.

Synchronization: Thread safe because all methods using static variables are synchronized.

Author:
Alvin Rearick (originators)

Field Summary
static int CENTER
           
static int NORTH_EAST_CORNER
           
static int NORTH_WEST_CORNER
           
 
Constructor Summary
WindowUtil()
           
 
Method Summary
static void addMouseListener(java.awt.Container container, java.awt.event.MouseListener listener)
          Recursively add a MouseListener to a container and all its components.
static void centerOnScreen(java.awt.Window window)
          Set the window location to center the window on the screen.
static void limitSizeBasedOnScreen(java.awt.Window window)
          Limit the window's initial size to the screen size.
static void putAtPosition(java.awt.Window window, int position)
          Places a Window at a particular position.
static void removeMouseListener(java.awt.Container container, java.awt.event.MouseListener listener)
          Recursively remove a MouseListener from a container and all its components.
static void setLocationRelativeToLast(java.awt.Point lastPoint, java.awt.Window window)
          Set the window location based on another location.
static void setLocationRelativeToLast(java.awt.Window window)
          Set the window location based on the previous call to the method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CENTER

public static final int CENTER
See Also:
Constant Field Values

NORTH_WEST_CORNER

public static final int NORTH_WEST_CORNER
See Also:
Constant Field Values

NORTH_EAST_CORNER

public static final int NORTH_EAST_CORNER
See Also:
Constant Field Values
Constructor Detail

WindowUtil

public WindowUtil()
Method Detail

setLocationRelativeToLast

public static void setLocationRelativeToLast(java.awt.Window window)
Set the window location based on the previous call to the method. The first time called the location will be 0, 0. Each subsequent method call moves both x and y 10 pixels to the right and down. If the window will not fit on the screen in a direction, the location will be set back to 0 for that dimension or if the y becomes greater than half the screen height, the y is set to 0.

Note: Because this method depends on the size of the window, the pack() method of the window and any other operations that may cause a change in the windows size should be completed before using this method.

Parameters:
window - to set the location on

setLocationRelativeToLast

public static void setLocationRelativeToLast(java.awt.Point lastPoint,
                                             java.awt.Window window)
Set the window location based on another location. Each call to this method moves both x and y 10 pixels to the right and down. If the window will not fit on the screen in a direction, the location will be set back to 0 for that dimension or if the y becomes greater than half the screen height, the y is set to 0.

Note: Because this method depends on the size of the window, the pack() method of the window and any other operations that may cause a change in the windows size should be completed before using this method.

Parameters:
lastPoint - specifies the location to use in calculating the new window placement. Normally this would start with a point of [0, 0] and on each call the values within the point are incremented.
window - to set the location on

limitSizeBasedOnScreen

public static void limitSizeBasedOnScreen(java.awt.Window window)
Limit the window's initial size to the screen size. Only affects the window if it is larger than the screen in at least one dimension.

Parameters:
window - to limit the size
Valid Values: Any Windows, nulls permitted.

centerOnScreen

public static void centerOnScreen(java.awt.Window window)
Set the window location to center the window on the screen.

Note: Because this method depends on the size of the windw, the pack() method of the window and any other operations that may cause a change in the windows size should be completed before using this method.

Parameters:
window - to set the location on
Valid Values: Any Windows, nulls permitted.

putAtPosition

public static void putAtPosition(java.awt.Window window,
                                 int position)
Places a Window at a particular position.

Parameters:
window - window to set the location of
Valid Values: Any Windows, nulls permitted.

addMouseListener

public static void addMouseListener(java.awt.Container container,
                                    java.awt.event.MouseListener listener)
Recursively add a MouseListener to a container and all its components.

Parameters:
container - to add the MouseListener to.
Valid Values: May not be null.
listener - to add
Valid Values: May not be null.

removeMouseListener

public static void removeMouseListener(java.awt.Container container,
                                       java.awt.event.MouseListener listener)
Recursively remove a MouseListener from a container and all its components.

Parameters:
container - to remove the MouseListener from.
Valid Values: May not be null.
listener - to remove
Valid Values: May not be null.


Copyright © 2002 Gerhard Beck. All rights reserved. Subject to GPL.