Package com.explodingpixels.widgets
Class WindowUtils
java.lang.Object
com.explodingpixels.widgets.WindowUtils
Utility methods for dealing with
Windows.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic WindowFocusListenerDeprecated.static voidInstalls a listener on the givenJComponent's parentWindowthat repaints the given component when the parent window's focused state changes.static voidinstallWeakWindowFocusListener(JComponent component, WindowFocusListener focusListener) static booleanisParentWindowFocused(Component component) static voidmakeWindowNonOpaque(Window window) Try's to make the givenWindownon-opqaue (transparent) across platforms and JREs.
-
Constructor Details
-
WindowUtils
public WindowUtils()
-
-
Method Details
-
makeWindowNonOpaque
Try's to make the givenWindownon-opqaue (transparent) across platforms and JREs. This method is not guaranteed to succeed, and will fail silently if the givenWindowcannot 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- theWindowto make non-opaque.
-
createAndInstallRepaintWindowFocusListener
@Deprecated public static WindowFocusListener createAndInstallRepaintWindowFocusListener(Window window) Deprecated.use the more targetedinstallJComponentRepainterOnWindowFocusChanged(JComponent)method.Creates and installs aWindowFocusListeneron the givenWindowwhich calls theWindow'srepaint()method on focus state changes.- Parameters:
window- theWindowto repaint on focus state changes.- Returns:
- the listener installed.
-
isParentWindowFocused
trueif the givenComponent's has a parentWindow(i.e. it's not null) and thatWindowis currently active (focused).- Parameters:
component- theComponentto check the parentWindow's focus for.- Returns:
trueif the givenComponent's parentWindowis currently active.
-
installWeakWindowFocusListener
public static void installWeakWindowFocusListener(JComponent component, WindowFocusListener focusListener) Installs aWindowFocusListeneron the givenJComponent's parentWindow. If theJComponentdoesn't yet have a parent, then the listener will be installed when the component is added to a container.- Parameters:
component- the component who's parent frame to listen to focus changes on.focusListener- theWindowFocusListenerto notify when focus changes.
-
installJComponentRepainterOnWindowFocusChanged
Installs a listener on the givenJComponent's parentWindowthat 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- theJComponentto add the repaint focus listener to.
-
installJComponentRepainterOnWindowFocusChanged(JComponent)method.