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
UIResource
s. - Support for new
UIResource
types, such asPainterUIResource
. - Support for the dynamic localization of
UIDefaults
. - Support for returning non-
String
localizations fromResourceBundle
s.
Safe Methods
The getSafeXXX
methods are designed for use with
LookAndFeelAddon
s. 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
ResourceBundle
s. 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 String
s 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
ResourceBundle
s are queried. UIManagerExt
will attempt to
convert any returned value to the appropriate type. For instance,
getInt
uses Integer.decode
to convert String
s
returned from the bundle into int
s.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Used to replicate the resource bundle behavior from theUIDefaults
. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addResourceBundle
(String bundleName) Adds a resource bundle to the list of resource bundles that are searched for localized values.static boolean
getBoolean
(Object key) Returns an Boolean from the defaults.static boolean
getBoolean
(Object key, Locale l) Returns an Boolean from the defaults.static Color
Returns a color from the defaults.static Color
Returns a color from the defaults.static int
Returns an integer from the defaults.static int
Returns 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 Border
getSafeBorder
(Object key, Border defaultBorder) Returns a border from the defaults.static Color
getSafeColor
(Object key, Color defaultColor) Returns a color from the defaults.static Dimension
getSafeDimension
(Object key, Dimension defaultDimension) Returns a dimension from the defaults.static Font
getSafeFont
(Object key, Font defaultFont) Returns a font from the defaults.static Icon
getSafeIcon
(Object key, Icon defaultIcon) Returns an icon from the defaults.static Insets
getSafeInsets
(Object key, Insets defaultInsets) Returns an insets from the defaults.static Shape
Returns a shape from the defaults.static Shape
Returns a shape from the defaults that is appropriate for the given locale.static String
Returns a string from the defaults.static String
Returns a string from the defaults.static void
removeResourceBundle
(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 forkey
is not aString
,null
is returned.- Parameters:
key
- anObject
specifying the string- Returns:
- the
String
object - Throws:
NullPointerException
- ifkey
isnull
-
getString
Returns a string from the defaults. If the value forkey
is not aString
,null
is returned.- Parameters:
key
- anObject
specifying the stringl
- theLocale
for which the string is desired; refer toUIDefaults
for details on how anull
Locale
is handled- Returns:
- the
String
object - Throws:
NullPointerException
- ifkey
isnull
-
getInt
Returns an integer from the defaults. If the value forkey
is not anint
,0
is returned.- Parameters:
key
- anObject
specifying the integer- Returns:
- the
int
- Throws:
NullPointerException
- ifkey
isnull
-
getInt
Returns an integer from the defaults. If the value forkey
is not anint
,0
is returned.- Parameters:
key
- anObject
specifying the integerl
- theLocale
for which the integer is desired; refer toUIDefaults
for details on how anull
Locale
is handled- Returns:
- the
int
- Throws:
NullPointerException
- ifkey
isnull
-
getBoolean
Returns an Boolean from the defaults. If the value forkey
is not aboolean
,false
is returned.- Parameters:
key
- anObject
specifying the Boolean- Returns:
- the
boolean
- Throws:
NullPointerException
- ifkey
isnull
-
getBoolean
Returns an Boolean from the defaults. If the value forkey
is not aboolean
,false
is returned.- Parameters:
key
- anObject
specifying the Booleanl
- theLocale
for which the Boolean is desired; refer toUIDefaults
for details on how anull
Locale
is handled- Returns:
- the
boolean
- Throws:
NullPointerException
- ifkey
isnull
-
getColor
Returns a color from the defaults. If the value forkey
is not aColor
,null
is returned.- Parameters:
key
- anObject
specifying the color- Returns:
- the
Color
object - Throws:
NullPointerException
- ifkey
isnull
-
getColor
Returns a color from the defaults. If the value forkey
is not aColor
,null
is returned.- Parameters:
key
- anObject
specifying the colorl
- theLocale
for which the color is desired; refer toUIDefaults
for details on how anull
Locale
is handled- Returns:
- the
Color
object - Throws:
NullPointerException
- ifkey
isnull
-
getShape
Returns a shape from the defaults. If the value forkey
is not aShape
,null
is returned.- Parameters:
key
- anObject
specifying the shape- Returns:
- the
Shape
object - Throws:
NullPointerException
- ifkey
isnull
-
getShape
Returns a shape from the defaults that is appropriate for the given locale. If the value forkey
is not aShape
,null
is returned.- Parameters:
key
- anObject
specifying the shapel
- theLocale
for which the shape is desired; refer toUIDefaults
for details on how anull
Locale
is handled- Returns:
- the
Shape
object - Throws:
NullPointerException
- ifkey
isnull
-
getPainter
Returns a painter from the defaults. If the value forkey
is not aPainter
,null
is returned.- Parameters:
key
- anObject
specifying the painter- Returns:
- the
Painter
object - Throws:
NullPointerException
- ifkey
isnull
-
getPainter
Returns a painter from the defaults that is appropriate for the given locale. If the value forkey
is not aPainter
,null
is returned.- Parameters:
key
- anObject
specifying the painterl
- theLocale
for which the painter is desired; refer toUIDefaults
for details on how anull
Locale
is handled- Returns:
- the
Painter
object - Throws:
NullPointerException
- ifkey
isnull
-
getSafeBorder
Returns a border from the defaults. If the value forkey
is not aBorder
,defaultBorder
is returned.- Parameters:
key
- anObject
specifying the borderdefaultBorder
- the border to return if the border specified bykey
does not exist- Returns:
- the
Border
object - Throws:
NullPointerException
- ifkey
ordefaultBorder
isnull
-
getSafeColor
Returns a color from the defaults. If the value forkey
is not aColor
,defaultColor
is returned.- Parameters:
key
- anObject
specifying the colordefaultColor
- the color to return if the color specified bykey
does not exist- Returns:
- the
Color
object - Throws:
NullPointerException
- ifkey
ordefaultColor
isnull
-
getSafeDimension
Returns a dimension from the defaults. If the value forkey
is not aDimension
,defaultDimension
is returned.- Parameters:
key
- anObject
specifying the dimensiondefaultDimension
- the dimension to return if the dimension specified bykey
does not exist- Returns:
- the
Dimension
object - Throws:
NullPointerException
- ifkey
ordefaultColor
isnull
-
getSafeFont
Returns a font from the defaults. If the value forkey
is not aFont
,defaultFont
is returned.- Parameters:
key
- anObject
specifying the fontdefaultFont
- the font to return if the font specified bykey
does not exist- Returns:
- the
Font
object - Throws:
NullPointerException
- ifkey
ordefaultFont
isnull
-
getSafeIcon
Returns an icon from the defaults. If the value forkey
is not aIcon
,defaultIcon
is returned.- Parameters:
key
- anObject
specifying the icondefaultIcon
- the icon to return if the icon specified bykey
does not exist- Returns:
- the
Icon
object - Throws:
NullPointerException
- ifkey
ordefaultIcon
isnull
-
getSafeInsets
Returns an insets from the defaults. If the value forkey
is not aInsets
,defaultInsets
is returned.- Parameters:
key
- anObject
specifying the insetsdefaultInsets
- the insets to return if the insets specified bykey
does not exist- Returns:
- the
Insets
object - Throws:
NullPointerException
- ifkey
ordefaultInsets
isnull
-