com.alee.utils
Class WindowUtils

java.lang.Object
  extended by com.alee.utils.WindowUtils

public final class WindowUtils
extends java.lang.Object

This class provides a set of utilities to modify application windows.

Author:
Mikle Garin

Constructor Summary
WindowUtils()
           
 
Method Summary
static
<W extends java.awt.Window>
W
center(W window)
          Centers window relative to screen center.
static
<W extends java.awt.Window>
W
center(W window, java.awt.Component relativeTo)
          Centers window relative to the specified component center.
static
<W extends java.awt.Window>
W
center(W window, java.awt.Component relativeTo, int width, int height)
          Changes window size and centers it relative to screen center.
static
<W extends java.awt.Window>
W
center(W window, int width, int height)
          Changes window size and centers it relative to screen center.
static
<W extends java.awt.Window>
float
getWindowOpacity(W window)
          Returns window opacity.
static
<W extends java.awt.Window>
boolean
isWindowOpaque(W window)
          Returns whether window is opaque or not.
static
<W extends java.awt.Window>
W
packAndCenter(W window)
          Packs and centers specified window relative to old position.
static
<W extends java.awt.Window>
W
packAndCenter(W window, boolean animate)
          Packs and centers specified window relative to old position.
static
<W extends java.awt.Window>
W
packToHeight(W window, int height)
          Packs window to its preffered width and specified height.
static
<W extends java.awt.Window>
W
packToWidth(W window, int width)
          Packs window to its preffered height and specified width.
static
<W extends java.awt.Window>
W
setWindowOpacity(W window, float opacity)
          Sets window opacity if that option is supported by the underlying system.
static
<W extends java.awt.Window>
W
setWindowOpaque(W window, boolean opaque)
          Sets window opaque if that option is supported by the underlying system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WindowUtils

public WindowUtils()
Method Detail

setWindowOpaque

public static <W extends java.awt.Window> W setWindowOpaque(W window,
                                                            boolean opaque)
Sets window opaque if that option is supported by the underlying system.

Type Parameters:
W - window type
Parameters:
window - window to modify
opaque - whether should make window opaque or not
Returns:
processed window

isWindowOpaque

public static <W extends java.awt.Window> boolean isWindowOpaque(W window)
Returns whether window is opaque or not.

Type Parameters:
W - window type
Parameters:
window - window to process
Returns:
whether window background is opaque or not

setWindowOpacity

public static <W extends java.awt.Window> W setWindowOpacity(W window,
                                                             float opacity)
Sets window opacity if that option is supported by the underlying system.

Type Parameters:
W - window type
Parameters:
window - window to modify
opacity - new window opacity
Returns:
processed window

getWindowOpacity

public static <W extends java.awt.Window> float getWindowOpacity(W window)
Returns window opacity.

Type Parameters:
W - window type
Parameters:
window - window to process
Returns:
window opacity

center

public static <W extends java.awt.Window> W center(W window)
Centers window relative to screen center.

Type Parameters:
W - window type
Parameters:
window - window to process
Returns:
processed window

center

public static <W extends java.awt.Window> W center(W window,
                                                   java.awt.Component relativeTo)
Centers window relative to the specified component center.

Type Parameters:
W - window type
Parameters:
window - window to process
relativeTo - component used to center window
Returns:
processed window

center

public static <W extends java.awt.Window> W center(W window,
                                                   int width,
                                                   int height)
Changes window size and centers it relative to screen center.

Type Parameters:
W - window type
Parameters:
window - window to process
width - new window width
height - new window height
Returns:
processed window

center

public static <W extends java.awt.Window> W center(W window,
                                                   java.awt.Component relativeTo,
                                                   int width,
                                                   int height)
Changes window size and centers it relative to screen center.

Type Parameters:
W - window type
Parameters:
window - window to process
relativeTo - component used to center window
width - new window width
height - new window height
Returns:
processed window

packToWidth

public static <W extends java.awt.Window> W packToWidth(W window,
                                                        int width)
Packs window to its preffered height and specified width.

Type Parameters:
W - window type
Parameters:
window - window to process
width - new window width
Returns:
processed window

packToHeight

public static <W extends java.awt.Window> W packToHeight(W window,
                                                         int height)
Packs window to its preffered width and specified height.

Type Parameters:
W - window type
Parameters:
window - window to process
height - new window height
Returns:
processed window

packAndCenter

public static <W extends java.awt.Window> W packAndCenter(W window)
Packs and centers specified window relative to old position. Bounds transition might also be animated, depending on StyleConstants.animate variable.

Type Parameters:
W - window type
Parameters:
window - window to process
Returns:
processed window
See Also:
StyleConstants.animate

packAndCenter

public static <W extends java.awt.Window> W packAndCenter(W window,
                                                          boolean animate)
Packs and centers specified window relative to old position. Bounds transition will be animated if requested.

Type Parameters:
W - window type
Parameters:
window - window to process
animate - whether should animate window size changes or not
Returns:
processed window