public final class Utilities extends Object
Modifier and Type | Method and Description |
---|---|
static void |
addInitialFocusHack(JComponent component,
Action onFocusAction)
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5018574
|
static void |
collapseAll(JTree tree,
TreePath parent)
Collapses all the paths from a parent in the given tree
|
static Color |
darker(Color color)
Returns a darker version of the given color, using 0.8 as the mulitiplication factor.
|
static Color |
darker(Color color,
double factor)
Returns a darker version of the given color, using the given factor.
|
static boolean |
disposeParentWindow(Component component)
Finds the parent Window and disposes it if found.
|
static void |
expandAll(JTree tree,
TreePath parent)
Expands all the paths from a parent in the given tree
|
static JDialog |
getParentDialog(Component component)
Finds the first component of type
JDialog in the parent hierarchy of component . |
static JFrame |
getParentFrame(Component component)
Finds the first component of type
JFrame in the parent hierarchy of component . |
static <T> T |
getParentOfType(Class<T> clazz,
Component component)
Searches the parent component hierarchy of the given component for
an ancestor of the given type
|
static Window |
getParentWindow(Component component)
Finds the first component of type
Window in the parent hierarchy of component . |
static boolean |
isSystemOrCrossPlatformLookAndFeelEnabled() |
static void |
linkBoundedRangeModels(BoundedRangeModel main,
BoundedRangeModel linked)
Links the given BoundedRangeModels so that changes in
main are reflected in linked |
static Action |
linkToEnabledState(StateObserver enabledState,
Action action)
Links the given action to the given StateObserver, so that the action is enabled
only when the observed state is active
|
static void |
linkToEnabledState(StateObserver enabledState,
JComponent... components)
Links the given components to the given StateObserver, so that each component is enabled only when the observed state is active
|
static ImageIcon |
loadIcon(Class<?> resourceClass,
String resourceName)
Loads an icon as a resource
|
static <T> EventObserver<T> |
propertyChangeObserver(JComponent component,
String property)
Returns a
EventObserver notified each time the value of the given property changes in the given component. |
static void |
setClipboard(String string)
Sets the given string as clipboard contents
|
static void |
setFontSizePercentage(int fontSizePercentage)
Sets a global font size percentage.
85 = decrease the default font size by 15% 100 = use the default font size 125 = increase the default font size by 25% |
static String |
systemLookAndFeelClassName()
Note that GTKLookAndFeel is overridden with MetalLookAndFeel, since JTabbedPane
does not respect the 'TabbedPane.contentBorderInsets' setting, making hierachical
tabbed panes look bad
|
static void |
updateUI(Collection<? extends JComponent> components)
Calls
JComponent.updateUI() for the given components, ignores null components. |
static void |
updateUI(JComponent... components)
Calls
JComponent.updateUI() for the given components, ignores null components. |
public static void updateUI(JComponent... components)
JComponent.updateUI()
for the given components, ignores null components.components
- the components to update the UI forpublic static void updateUI(Collection<? extends JComponent> components)
JComponent.updateUI()
for the given components, ignores null components.components
- the components to update the UI forpublic static Action linkToEnabledState(StateObserver enabledState, Action action)
enabledState
- the StateObserver with which to link the actionaction
- the actionpublic static void linkToEnabledState(StateObserver enabledState, JComponent... components)
enabledState
- the StateObserver with which to link the componentscomponents
- the componentspublic static <T> EventObserver<T> propertyChangeObserver(JComponent component, String property)
EventObserver
notified each time the value of the given property changes in the given component.T
- the property data typecomponent
- the componentproperty
- the property to listen to changes forEventObserver
notified each time the value of the given property changespublic static void linkBoundedRangeModels(BoundedRangeModel main, BoundedRangeModel linked)
main
are reflected in linked
main
- the main modellinked
- the model to link with mainpublic static void expandAll(JTree tree, TreePath parent)
tree
- the treeparent
- the parent from which to exapandpublic static void collapseAll(JTree tree, TreePath parent)
tree
- the treeparent
- the parent from which to collapsepublic static void addInitialFocusHack(JComponent component, Action onFocusAction)
component
- the componentonFocusAction
- the action to run when the focus has been requestedpublic static ImageIcon loadIcon(Class<?> resourceClass, String resourceName)
resourceClass
- the class owning the resourceresourceName
- the resource namepublic static void setFontSizePercentage(int fontSizePercentage)
fontSizePercentage
- the font size percentagepublic static Color darker(Color color)
color
- the color to darkenColor.darker()
public static Color darker(Color color, double factor)
color
- the color to darkenfactor
- a number between 0 and 1, non-inclusiveColor.darker()
public static void setClipboard(String string)
string
- the string to put on the clipboardpublic static <T> T getParentOfType(Class<T> clazz, Component component)
T
- the type of parent to findclazz
- the class of the parent to findcomponent
- the componentpublic static Window getParentWindow(Component component)
Window
in the parent hierarchy of component
.
Note that if component
is of type Window
, it is returned.component
- the componentpublic static JFrame getParentFrame(Component component)
JFrame
in the parent hierarchy of component
.
Note that if component
is of type JFrame
, it is returned.component
- the componentpublic static JDialog getParentDialog(Component component)
JDialog
in the parent hierarchy of component
.
Note that if component
is of type JDialog
, it is returned.component
- the componentpublic static boolean disposeParentWindow(Component component)
component
- the component which parent Window should be disposedpublic static String systemLookAndFeelClassName()
public static boolean isSystemOrCrossPlatformLookAndFeelEnabled()
systemLookAndFeelClassName()