com.explodingpixels.widgets
Class WindowUtils

java.lang.Object
  extended by com.explodingpixels.widgets.WindowUtils

public class WindowUtils
extends Object


Constructor Summary
WindowUtils()
           
 
Method Summary
static WindowFocusListener createAndInstallRepaintWindowFocusListener(Window window)
           
static void installJComponentRepainterOnWindowFocusChanged(JComponent component)
          Installs a listener on the given JComponent's parent Window that repaints the given component when the parent window's focused state changes.
static void installWindowFocusListener(WindowFocusListener focusListener, JComponent component)
           
static boolean isParentWindowFocused(Component component)
          true if the given Component's parent Window is currently active (focused).
static void makeWindowNonOpaque(Window window)
          Try's to make the given Window non-opqaue (transparent) across platforms and JREs.
 
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

makeWindowNonOpaque

public static void makeWindowNonOpaque(Window window)
Try's to make the given Window non-opqaue (transparent) across platforms and JREs. This method is not guaranteed to succeed, and will fail silently if the given Window cannot be made non-opaque.

This method is useful, for example, when creating a HUD style window that is semi-transparent, and thus doesn't want the window background to be drawn.

Parameters:
window - the Window to make non-opaque.

createAndInstallRepaintWindowFocusListener

public static WindowFocusListener createAndInstallRepaintWindowFocusListener(Window window)

isParentWindowFocused

public static boolean isParentWindowFocused(Component component)
true if the given Component's parent Window is currently active (focused).

Parameters:
component - the Component to check the parent Window's focus for.
Returns:
true if the given Component's parent Window is currently active.

installWindowFocusListener

public static void installWindowFocusListener(WindowFocusListener focusListener,
                                              JComponent component)

installJComponentRepainterOnWindowFocusChanged

public static void installJComponentRepainterOnWindowFocusChanged(JComponent component)
Installs a listener on the given JComponent's parent Window that repaints the given component when the parent window's focused state changes. If the given component does not have a parent at the time this method is called, then an ancestor listener will be installed that installs a window listener when the components parent changes.

Parameters:
component - the JComponent to add the repaint focus listener to.