Class UIManagerExt
UIDefaults. This class handles SwingX-specific Linvalid input: '&F' needs, such as
the installation of painters and shapes. There are several categories of
utility methods:
- Support for the safe creation of
UIResources. - Support for new
UIResourcetypes, such asPainterUIResource. - Support for the dynamic localization of
UIDefaults. - Support for returning non-
Stringlocalizations fromResourceBundles.
Safe Methods
The getSafeXXX methods are designed for use with
LookAndFeelAddons. Any addon that attempts to obtain a property
defined in the defaults (available from UIManager.get) to set a
property that will be added to the defaults for the addon should use the
"safe" methods. The methods ensure that a valid value is always returned and
that value is a UIResource.
Support for New Types
UIManagerExt supports the retrieval of new UIResource types.
There is a getXXX method for every UIResource subtype in the
org.jdesktop.swingx.plaf package.
Support for Dynamic Localization
UIManagerExt enables dynamic localization by supporting
ResourceBundles. The
UIDefaults.addResourceBundle(String) allows resource bundles to
be added to the UIDefaults. While there is support for this feature
in core, there is a bug with the class loader that prevents user added
bundles from working correctly when used via Web Start. Therefore,
UIManagerExt defines methods to add and remove resource bundles.
These are the only methods that SwingX classes should use when adding
resource bundles to the defaults. Since UIManagerExt is maintaining
the bundles, any localized Strings must be retrieved from
the getString methods in this class.
Support for Non-String Localization Values
All methods work by first determining if the value is present
UIDefaults. If the value is not present, then the installed
ResourceBundles are queried. UIManagerExt will attempt to
convert any returned value to the appropriate type. For instance,
getInt uses Integer.decode to convert Strings
returned from the bundle into ints.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classUsed to replicate the resource bundle behavior from theUIDefaults. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddResourceBundle(String bundleName) Adds a resource bundle to the list of resource bundles that are searched for localized values.static booleangetBoolean(Object key) Returns an Boolean from the defaults.static booleangetBoolean(Object key, Locale l) Returns an Boolean from the defaults.static ColorReturns a color from the defaults.static ColorReturns a color from the defaults.static intReturns an integer from the defaults.static intReturns an integer from the defaults.static Painter<?> getPainter(Object key) Returns a painter from the defaults.static Painter<?> getPainter(Object key, Locale l) Returns a painter from the defaults that is appropriate for the given locale.static BordergetSafeBorder(Object key, Border defaultBorder) Returns a border from the defaults.static ColorgetSafeColor(Object key, Color defaultColor) Returns a color from the defaults.static DimensiongetSafeDimension(Object key, Dimension defaultDimension) Returns a dimension from the defaults.static FontgetSafeFont(Object key, Font defaultFont) Returns a font from the defaults.static IcongetSafeIcon(Object key, Icon defaultIcon) Returns an icon from the defaults.static InsetsgetSafeInsets(Object key, Insets defaultInsets) Returns an insets from the defaults.static ShapeReturns a shape from the defaults.static ShapeReturns a shape from the defaults that is appropriate for the given locale.static StringReturns a string from the defaults.static StringReturns a string from the defaults.static voidremoveResourceBundle(String bundleName) Removes a resource bundle from the list of resource bundles that are searched for localized defaults.
-
Field Details
-
uiDefaultsExt
-
-
Constructor Details
-
UIManagerExt
private UIManagerExt()
-
-
Method Details
-
addResourceBundle
Adds a resource bundle to the list of resource bundles that are searched for localized values. Resource bundles are searched in the reverse order they were added. In other words, the most recently added bundle is searched first.- Parameters:
bundleName- the base name of the resource bundle to be added- See Also:
-
removeResourceBundle
Removes a resource bundle from the list of resource bundles that are searched for localized defaults.- Parameters:
bundleName- the base name of the resource bundle to be removed- See Also:
-
getString
Returns a string from the defaults. If the value forkeyis not aString,nullis returned.- Parameters:
key- anObjectspecifying the string- Returns:
- the
Stringobject - Throws:
NullPointerException- ifkeyisnull
-
getString
Returns a string from the defaults. If the value forkeyis not aString,nullis returned.- Parameters:
key- anObjectspecifying the stringl- theLocalefor which the string is desired; refer toUIDefaultsfor details on how anullLocaleis handled- Returns:
- the
Stringobject - Throws:
NullPointerException- ifkeyisnull
-
getInt
Returns an integer from the defaults. If the value forkeyis not anint,0is returned.- Parameters:
key- anObjectspecifying the integer- Returns:
- the
int - Throws:
NullPointerException- ifkeyisnull
-
getInt
Returns an integer from the defaults. If the value forkeyis not anint,0is returned.- Parameters:
key- anObjectspecifying the integerl- theLocalefor which the integer is desired; refer toUIDefaultsfor details on how anullLocaleis handled- Returns:
- the
int - Throws:
NullPointerException- ifkeyisnull
-
getBoolean
Returns an Boolean from the defaults. If the value forkeyis not aboolean,falseis returned.- Parameters:
key- anObjectspecifying the Boolean- Returns:
- the
boolean - Throws:
NullPointerException- ifkeyisnull
-
getBoolean
Returns an Boolean from the defaults. If the value forkeyis not aboolean,falseis returned.- Parameters:
key- anObjectspecifying the Booleanl- theLocalefor which the Boolean is desired; refer toUIDefaultsfor details on how anullLocaleis handled- Returns:
- the
boolean - Throws:
NullPointerException- ifkeyisnull
-
getColor
Returns a color from the defaults. If the value forkeyis not aColor,nullis returned.- Parameters:
key- anObjectspecifying the color- Returns:
- the
Colorobject - Throws:
NullPointerException- ifkeyisnull
-
getColor
Returns a color from the defaults. If the value forkeyis not aColor,nullis returned.- Parameters:
key- anObjectspecifying the colorl- theLocalefor which the color is desired; refer toUIDefaultsfor details on how anullLocaleis handled- Returns:
- the
Colorobject - Throws:
NullPointerException- ifkeyisnull
-
getShape
Returns a shape from the defaults. If the value forkeyis not aShape,nullis returned.- Parameters:
key- anObjectspecifying the shape- Returns:
- the
Shapeobject - Throws:
NullPointerException- ifkeyisnull
-
getShape
Returns a shape from the defaults that is appropriate for the given locale. If the value forkeyis not aShape,nullis returned.- Parameters:
key- anObjectspecifying the shapel- theLocalefor which the shape is desired; refer toUIDefaultsfor details on how anullLocaleis handled- Returns:
- the
Shapeobject - Throws:
NullPointerException- ifkeyisnull
-
getPainter
Returns a painter from the defaults. If the value forkeyis not aPainter,nullis returned.- Parameters:
key- anObjectspecifying the painter- Returns:
- the
Painterobject - Throws:
NullPointerException- ifkeyisnull
-
getPainter
Returns a painter from the defaults that is appropriate for the given locale. If the value forkeyis not aPainter,nullis returned.- Parameters:
key- anObjectspecifying the painterl- theLocalefor which the painter is desired; refer toUIDefaultsfor details on how anullLocaleis handled- Returns:
- the
Painterobject - Throws:
NullPointerException- ifkeyisnull
-
getSafeBorder
Returns a border from the defaults. If the value forkeyis not aBorder,defaultBorderis returned.- Parameters:
key- anObjectspecifying the borderdefaultBorder- the border to return if the border specified bykeydoes not exist- Returns:
- the
Borderobject - Throws:
NullPointerException- ifkeyordefaultBorderisnull
-
getSafeColor
Returns a color from the defaults. If the value forkeyis not aColor,defaultColoris returned.- Parameters:
key- anObjectspecifying the colordefaultColor- the color to return if the color specified bykeydoes not exist- Returns:
- the
Colorobject - Throws:
NullPointerException- ifkeyordefaultColorisnull
-
getSafeDimension
Returns a dimension from the defaults. If the value forkeyis not aDimension,defaultDimensionis returned.- Parameters:
key- anObjectspecifying the dimensiondefaultDimension- the dimension to return if the dimension specified bykeydoes not exist- Returns:
- the
Dimensionobject - Throws:
NullPointerException- ifkeyordefaultColorisnull
-
getSafeFont
Returns a font from the defaults. If the value forkeyis not aFont,defaultFontis returned.- Parameters:
key- anObjectspecifying the fontdefaultFont- the font to return if the font specified bykeydoes not exist- Returns:
- the
Fontobject - Throws:
NullPointerException- ifkeyordefaultFontisnull
-
getSafeIcon
Returns an icon from the defaults. If the value forkeyis not aIcon,defaultIconis returned.- Parameters:
key- anObjectspecifying the icondefaultIcon- the icon to return if the icon specified bykeydoes not exist- Returns:
- the
Iconobject - Throws:
NullPointerException- ifkeyordefaultIconisnull
-
getSafeInsets
Returns an insets from the defaults. If the value forkeyis not aInsets,defaultInsetsis returned.- Parameters:
key- anObjectspecifying the insetsdefaultInsets- the insets to return if the insets specified bykeydoes not exist- Returns:
- the
Insetsobject - Throws:
NullPointerException- ifkeyordefaultInsetsisnull
-