public final class SwingXUtilities extends Object
Modifier and Type | Field and Description |
---|---|
private static String |
STYLESHEET |
Modifier | Constructor and Description |
---|---|
private |
SwingXUtilities() |
Modifier and Type | Method and Description |
---|---|
static void |
adjustFocus(JComponent component) |
static int |
convertModifiersToDropAction(int modifiers,
int sourcActions) |
static <T> T |
getAncestor(Class<T> clazz,
Component c)
An improved version of
SwingUtilities.getAncestorOfClass(Class, Component) . |
private static Component[] |
getChildren(Component c) |
(package private) static RepaintManager |
getTranslucentRepaintManager(RepaintManager delegate)
Obtains a
TranslucentRepaintManager from the specified manager. |
(package private) static <C extends JComponent & BackgroundPaintable> |
installBackground(C comp,
Color color) |
static <T> T |
invokeAndWait(Callable<T> callable)
A version of
SwingUtilities.invokeAndWait(Runnable) that supports return values. |
static <T> FutureTask<T> |
invokeLater(Callable<T> callable)
A version of
SwingUtilities.invokeLater(Runnable) that supports return values. |
static boolean |
isDescendingFrom(Component focusOwner,
Component parent)
Returns whether the component is part of the parent's
container hierarchy.
|
static boolean |
isUIInstallable(Object property)
Checks and returns whether the given property should be replaced
by the UI's default value.
|
static int |
loc2IndexFileList(JList list,
Point point) |
(package private) static <C extends JComponent & BackgroundPaintable> |
paintBackground(C comp,
Graphics2D g) |
private static boolean |
pointIsInActualBounds(JList list,
int index,
Point point) |
static void |
setComponentTreeBackground(Component c,
Color color)
Sets the background for an entire component hierarchy to the specified
color.
|
static void |
setComponentTreeEnabled(Component c,
boolean enabled)
Enables or disables of the components in the tree starting with
c . |
static void |
setComponentTreeFont(Component c,
Font font)
Sets the font for an entire component hierarchy to the specified font.
|
static void |
setComponentTreeForeground(Component c,
Color color)
Sets the foreground for an entire component hierarchy to the specified
color.
|
static void |
setComponentTreeLocale(Component c,
Locale locale)
Sets the locale for an entire component hierarchy to the specified
locale.
|
static void |
setHtmlFont(HTMLDocument doc,
Font font)
Sets the font used for HTML displays to the specified font.
|
static void |
setLeadAnchorWithoutSelection(ListSelectionModel selectionModel,
int lead,
int anchor)
Updates lead and anchor selection index without changing the selection.
|
static boolean |
shouldIgnore(MouseEvent mouseEvent,
JComponent component) |
static void |
updateAllComponentTreeUIs()
Updates the componentTreeUI of all top-level windows of the
current application.
|
static void |
updateAllComponentTreeUIs(Window window)
Updates the componentTreeUI of the given window and all its
owned windows, recursively.
|
static void |
updateMnemonicBinding(JComponent c,
String pressed)
A helper for creating and updating key bindings for components with
mnemonics.
|
static void |
updateMnemonicBinding(JComponent c,
String pressed,
String released)
A helper for creating and updating key bindings for components with
mnemonics.
|
private static String STYLESHEET
private SwingXUtilities()
public static void updateMnemonicBinding(JComponent c, String pressed)
pressed
action will be invoked when the mnemonic
is activated.
TODO establish an interface for the mnemonic properties, such as MnemonicEnabled
and change signature to public static <T extends
JComponent & MnemonicEnabled> void updateMnemonicBinding(T c, String
pressed)
c
- the component bindings to updatepressed
- the name of the action in the action map to invoke when the
mnemonic is pressedNullPointerException
- if the component is null
public static void updateMnemonicBinding(JComponent c, String pressed, String released)
pressed
action will be invoked when the mnemonic
is activated and the released
action will be invoked when the
mnemonic is deactivated.
TODO establish an interface for the mnemonic properties, such as MnemonicEnabled
and change signature to public static <T extends
JComponent & MnemonicEnabled> void updateMnemonicBinding(T c, String
pressed, String released)
c
- the component bindings to updatepressed
- the name of the action in the action map to invoke when the
mnemonic is pressedreleased
- the name of the action in the action map to invoke when the
mnemonic is released (if the action is a toggle style, then
this parameter should be null
)NullPointerException
- if the component is null
static <C extends JComponent & BackgroundPaintable> void installBackground(C comp, Color color)
static <C extends JComponent & BackgroundPaintable> void paintBackground(C comp, Graphics2D g)
private static Component[] getChildren(Component c)
public static void setComponentTreeEnabled(Component c, boolean enabled)
c
.c
- the starting componentenabled
- true
if the component is to enabled; false
otherwisepublic static void setComponentTreeLocale(Component c, Locale locale)
c
- the starting componentlocale
- the locale to setpublic static void setComponentTreeBackground(Component c, Color color)
c
- the starting componentcolor
- the color to setpublic static void setComponentTreeForeground(Component c, Color color)
c
- the starting componentcolor
- the color to setpublic static void setComponentTreeFont(Component c, Font font)
c
- the starting componentfont
- the font to setpublic static void setHtmlFont(HTMLDocument doc, Font font)
setHtmlFont
after the data is set will force the HTML display to use the font
specified to this method.doc
- the HTML document to updatefont
- the font to useNullPointerException
- if any parameter is null
public static void updateAllComponentTreeUIs()
public static void updateAllComponentTreeUIs(Window window)
window
- the window to updatepublic static <T> FutureTask<T> invokeLater(Callable<T> callable)
SwingUtilities.invokeLater(Runnable)
that supports return values.T
- the return type of the callablecallable
- the callable to executeCallable
public static <T> T invokeAndWait(Callable<T> callable) throws InterruptedException, InvocationTargetException
SwingUtilities.invokeAndWait(Runnable)
that supports return values.T
- the return type of the callablecallable
- the callable to executeInterruptedException
- if we're interrupted while waiting for the event dispatching thread to finish
executing callable.call()
InvocationTargetException
- if an exception is thrown while running callable
Callable
public static <T> T getAncestor(Class<T> clazz, Component c)
SwingUtilities.getAncestorOfClass(Class, Component)
. This method
traverses JPopupMenu
invoker and uses generics to return an
appropriately typed object.T
- the type of ancestor to findclazz
- the class instance of the ancestor to findc
- the component to start the search fromnull
if no such
ancestor exists. This method also returns null
if any
parameter is null
.public static boolean isDescendingFrom(Component focusOwner, Component parent)
focusOwner
- parent
- static RepaintManager getTranslucentRepaintManager(RepaintManager delegate)
TranslucentRepaintManager
from the specified manager.
If the current manager is a TranslucentRepaintManager
or a
ForwardingRepaintManager
that contains a TranslucentRepaintManager
, then the passed in manager is returned.
Otherwise a new repaint manager is created and returned.delegate
- the current repaint managernull
TranslucentRepaintManager
NullPointerException
- if delegate
is null
public static boolean isUIInstallable(Object property)
property
- the property to check.public static void setLeadAnchorWithoutSelection(ListSelectionModel selectionModel, int lead, int anchor)
selectionModel
- the selection model to change lead/anchorlead
- the lead selection indexanchor
- the anchor selection indexpublic static boolean shouldIgnore(MouseEvent mouseEvent, JComponent component)
public static int loc2IndexFileList(JList list, Point point)
private static boolean pointIsInActualBounds(JList list, int index, Point point)
public static void adjustFocus(JComponent component)
public static int convertModifiersToDropAction(int modifiers, int sourcActions)
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses