Package com.explodingpixels.widgets
Class WindowUtils
- java.lang.Object
-
- com.explodingpixels.widgets.WindowUtils
-
public class WindowUtils extends java.lang.Object
Utility methods for dealing withWindow
s.
-
-
Constructor Summary
Constructors Constructor Description WindowUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.awt.event.WindowFocusListener
createAndInstallRepaintWindowFocusListener(java.awt.Window window)
Deprecated.use the more targetedinstallJComponentRepainterOnWindowFocusChanged(JComponent)
method.static void
installJComponentRepainterOnWindowFocusChanged(javax.swing.JComponent component)
Installs a listener on the givenJComponent
's parentWindow
that repaints the given component when the parent window's focused state changes.static void
installWeakWindowFocusListener(javax.swing.JComponent component, java.awt.event.WindowFocusListener focusListener)
Installs aWindowFocusListener
on the givenJComponent
's parentWindow
.static boolean
isParentWindowFocused(java.awt.Component component)
true
if the givenComponent
's has a parentWindow
(i.e.static void
makeWindowNonOpaque(java.awt.Window window)
Try's to make the givenWindow
non-opqaue (transparent) across platforms and JREs.
-
-
-
Method Detail
-
makeWindowNonOpaque
public static void makeWindowNonOpaque(java.awt.Window window)
Try's to make the givenWindow
non-opqaue (transparent) across platforms and JREs. This method is not guaranteed to succeed, and will fail silently if the givenWindow
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
- theWindow
to make non-opaque.
-
createAndInstallRepaintWindowFocusListener
@Deprecated public static java.awt.event.WindowFocusListener createAndInstallRepaintWindowFocusListener(java.awt.Window window)
Deprecated.use the more targetedinstallJComponentRepainterOnWindowFocusChanged(JComponent)
method.Creates and installs aWindowFocusListener
on the givenWindow
which calls theWindow
'srepaint()
method on focus state changes.- Parameters:
window
- theWindow
to repaint on focus state changes.- Returns:
- the listener installed.
-
isParentWindowFocused
public static boolean isParentWindowFocused(java.awt.Component component)
true
if the givenComponent
's has a parentWindow
(i.e. it's not null) and thatWindow
is currently active (focused).- Parameters:
component
- theComponent
to check the parentWindow
's focus for.- Returns:
true
if the givenComponent
's parentWindow
is currently active.
-
installWeakWindowFocusListener
public static void installWeakWindowFocusListener(javax.swing.JComponent component, java.awt.event.WindowFocusListener focusListener)
Installs aWindowFocusListener
on the givenJComponent
's parentWindow
. If theJComponent
doesn'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
- theWindowFocusListener
to notify when focus changes.
-
installJComponentRepainterOnWindowFocusChanged
public static void installJComponentRepainterOnWindowFocusChanged(javax.swing.JComponent component)
Installs a listener on the givenJComponent
's parentWindow
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
- theJComponent
to add the repaint focus listener to.
-
-