org.jdesktop.swingx.util
Class WindowUtils

java.lang.Object
  extended by org.jdesktop.swingx.util.WindowUtils

public final class WindowUtils
extends Object

Encapsulates various utilities for windows (ie: Frame and Dialog objects and descendants, in particular).


Nested Class Summary
static class WindowUtils.MinSizeComponentListener
          Resets window size to minSize if needed.
 
Method Summary
static JDialog findJDialog(Component c)
          Deprecated. (pre-0.9.6) use SwingXUtilities#getAncestor(Class, Component).
static JFrame findJFrame(Component c)
          Deprecated. (pre-0.9.6) use SwingXUtilities#getAncestor(Class, Component).
static RootPaneContainer findRootPaneContainer(Component c)
          Deprecated. (pre-0.9.6) use SwingXUtilities#getAncestor(Class, Component).
static Window findWindow(Component c)
           
static List<Component> getAllComponents(Container c)
           
static Point getPointForCentering(JInternalFrame window)
          

Returns the Point at which a window should be placed to center that window on the given desktop.

static Point getPointForCentering(Window window)
          

Returns the Point at which a window should be placed to center that window on the screen.

static Point getPointForStaggering(Window originWindow)
          

Returns the Point at which a window should be placed in order to be staggered slightly from another "origin" window to ensure that the title areas of both windows remain visible to the user.

static Rectangle getRectangle(JComponent comp)
          Deprecated. (pre-0.9.6) use JComponent#getBounds().
static Rectangle getRectangle(Window win)
          Deprecated. (pre-0.9.6) use Window#getBounds().
static void setConstraints(GridBagConstraints gbc, int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, int anchor, int fill, int top, int left, int bottom, int right)
          Deprecated. (pre 0.9.6) no replacement
static void setFontRecursively(Container c, Font font)
          Deprecated. (pre-0.9.6) use SwingXUtilities.setComponentTreeFont(Component, Font)
static void setMinimumSizeManager(Window window, int minWidth, int minHeight)
          Installs/resets a ComponentListener to resize the given window to minWidth/Height if needed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getPointForCentering

public static Point getPointForCentering(Window window)

Returns the Point at which a window should be placed to center that window on the screen.

Some thought was taken as to whether to implement a method such as this, or to simply make a method that, given a window, will center it. It was decided that it is better to not alter an object within a method.

Parameters:
window - The window to calculate the center point for. This object can not be null.
Returns:
the Point at which the window should be placed to center that window on the screen.

getPointForCentering

public static Point getPointForCentering(JInternalFrame window)

Returns the Point at which a window should be placed to center that window on the given desktop.

Some thought was taken as to whether to implement a method such as this, or to simply make a method that, given a window, will center it. It was decided that it is better to not alter an object within a method.

Parameters:
window - The window (JInternalFrame) to calculate the center point for. This object can not be null.
Returns:
the Point at which the window should be placed to center that window on the given desktop

getPointForStaggering

public static Point getPointForStaggering(Window originWindow)

Returns the Point at which a window should be placed in order to be staggered slightly from another "origin" window to ensure that the title areas of both windows remain visible to the user.

Parameters:
originWindow - Window from which the staggered location will be calculated
Returns:
location staggered from the upper left location of the origin window

setConstraints

@Deprecated
public static void setConstraints(GridBagConstraints gbc,
                                             int gridx,
                                             int gridy,
                                             int gridwidth,
                                             int gridheight,
                                             double weightx,
                                             double weighty,
                                             int anchor,
                                             int fill,
                                             int top,
                                             int left,
                                             int bottom,
                                             int right)
Deprecated. (pre 0.9.6) no replacement

Utility method used to load a GridBagConstraints object (param gbc) with the data in the other parameters. This method saves code space over doing the assignments by hand, and also allows you to reuse the same GridBagConstraints object reducing temporary object creating (at the expense of a method call. Go figure).


getRectangle

@Deprecated
public static Rectangle getRectangle(Window win)
Deprecated. (pre-0.9.6) use Window#getBounds().

Get a Rectangle object representing the given window's position and magnitude in space.

Parameters:
win - The window to get a Rectangle object for
Returns:
a Rectangle object.
See Also:
com.jgui.Rectangle

getRectangle

@Deprecated
public static Rectangle getRectangle(JComponent comp)
Deprecated. (pre-0.9.6) use JComponent#getBounds().

Get a Rectangle object representing the given JComponent's position and magnitude in space.

Parameters:
comp - The JComponent to get a Rectangle object for
Returns:
a Rectangle object.
See Also:
com.jgui.Rectangle

findRootPaneContainer

@Deprecated
public static RootPaneContainer findRootPaneContainer(Component c)
Deprecated. (pre-0.9.6) use SwingXUtilities#getAncestor(Class, Component).

Locates the RootPaneContainer for the given component

Parameters:
c -
Returns:
the RootPaneContainer to which the component belongs to

findJFrame

@Deprecated
public static JFrame findJFrame(Component c)
Deprecated. (pre-0.9.6) use SwingXUtilities#getAncestor(Class, Component).

Locates the JFrame for the given component

Parameters:
c -
Returns:
the JFrame to which the component belongs to

findJDialog

@Deprecated
public static JDialog findJDialog(Component c)
Deprecated. (pre-0.9.6) use SwingXUtilities#getAncestor(Class, Component).

Locates the JDialog for the given component

Parameters:
c -
Returns:
the JDialog to which the component belongs to

findWindow

public static Window findWindow(Component c)

getAllComponents

public static List<Component> getAllComponents(Container c)

setFontRecursively

@Deprecated
public static void setFontRecursively(Container c,
                                                 Font font)
Deprecated. (pre-0.9.6) use SwingXUtilities.setComponentTreeFont(Component, Font)


setMinimumSizeManager

public static void setMinimumSizeManager(Window window,
                                         int minWidth,
                                         int minHeight)
Installs/resets a ComponentListener to resize the given window to minWidth/Height if needed.

Parameters:
window -
minWidth -
minHeight -