public class UIManagerExt extends Object
UIDefaults
. This class handles SwingX-specific L&F needs, such as
the installation of painters and shapes. There are several categories of
utility methods:
UIResource
s.UIResource
types, such as
PainterUIResource
.UIDefaults
.String
localizations from
ResourceBundle
s.
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
.
UIManagerExt
supports the retrieval of new UIResource
types.
There is a getXXX
method for every UIResource
subtype in the
org.jdesktop.swingx.plaf
package.
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.
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.
UIManager
,
UIDefaults
Modifier and Type | Class and Description |
---|---|
private static class |
UIManagerExt.UIDefaultsExt
Used to replicate the resource bundle behavior from the
UIDefaults . |
Modifier and Type | Field and Description |
---|---|
private static UIManagerExt.UIDefaultsExt |
uiDefaultsExt |
Modifier | Constructor and Description |
---|---|
private |
UIManagerExt() |
Modifier and Type | Method and Description |
---|---|
static 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 |
getColor(Object key)
Returns a color from the defaults.
|
static Color |
getColor(Object key,
Locale l)
Returns a color from the defaults.
|
static int |
getInt(Object key)
Returns an integer from the defaults.
|
static int |
getInt(Object key,
Locale l)
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 |
getShape(Object key)
Returns a shape from the defaults.
|
static Shape |
getShape(Object key,
Locale l)
Returns a shape from the defaults that is appropriate for the given
locale.
|
static String |
getString(Object key)
Returns a string from the defaults.
|
static String |
getString(Object key,
Locale l)
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.
|
private static UIManagerExt.UIDefaultsExt uiDefaultsExt
private UIManagerExt()
public static void addResourceBundle(String bundleName)
bundleName
- the base name of the resource bundle to be addedResourceBundle
,
removeResourceBundle(java.lang.String)
public static void removeResourceBundle(String bundleName)
bundleName
- the base name of the resource bundle to be removedResourceBundle
,
addResourceBundle(java.lang.String)
public static String getString(Object key)
key
is not a
String
, null
is returned.key
- an Object
specifying the stringString
objectNullPointerException
- if key
is null
public static String getString(Object key, Locale l)
key
is not a
String
, null
is returned.key
- an Object
specifying the stringl
- the Locale
for which the string is desired; refer
to UIDefaults
for details on how a null
Locale
is handledString
objectNullPointerException
- if key
is null
public static int getInt(Object key)
key
is not
an int
, 0
is returned.key
- an Object
specifying the integerint
NullPointerException
- if key
is null
public static int getInt(Object key, Locale l)
key
is not
an int
, 0
is returned.key
- an Object
specifying the integerl
- the Locale
for which the integer is desired; refer
to UIDefaults
for details on how a null
Locale
is handledint
NullPointerException
- if key
is null
public static boolean getBoolean(Object key)
key
is not
a boolean
, false
is returned.key
- an Object
specifying the Booleanboolean
NullPointerException
- if key
is null
public static boolean getBoolean(Object key, Locale l)
key
is not
a boolean
, false
is returned.key
- an Object
specifying the Booleanl
- the Locale
for which the Boolean is desired; refer
to UIDefaults
for details on how a null
Locale
is handledboolean
NullPointerException
- if key
is null
public static Color getColor(Object key)
key
is not
a Color
, null
is returned.key
- an Object
specifying the colorColor
objectNullPointerException
- if key
is null
public static Color getColor(Object key, Locale l)
key
is not
a Color
, null
is returned.key
- an Object
specifying the colorl
- the Locale
for which the color is desired; refer
to UIDefaults
for details on how a null
Locale
is handledColor
objectNullPointerException
- if key
is null
public static Shape getShape(Object key)
key
is not a
Shape
, null
is returned.key
- an Object
specifying the shapeShape
objectNullPointerException
- if key
is null
public static Shape getShape(Object key, Locale l)
key
is not a Shape
,
null
is returned.key
- an Object
specifying the shapel
- the Locale
for which the shape is desired; refer
to UIDefaults
for details on how a null
Locale
is handledShape
objectNullPointerException
- if key
is null
public static Painter<?> getPainter(Object key)
key
is not
a Painter
, null
is returned.key
- an Object
specifying the painterPainter
objectNullPointerException
- if key
is null
public static Painter<?> getPainter(Object key, Locale l)
key
is not a Painter
,
null
is returned.key
- an Object
specifying the painterl
- the Locale
for which the painter is desired; refer
to UIDefaults
for details on how a null
Locale
is handledPainter
objectNullPointerException
- if key
is null
public static Border getSafeBorder(Object key, Border defaultBorder)
key
is not a
Border
, defaultBorder
is returned.key
- an Object
specifying the borderdefaultBorder
- the border to return if the border specified by
key
does not existBorder
objectNullPointerException
- if key
or defaultBorder
is null
public static Color getSafeColor(Object key, Color defaultColor)
key
is not a
Color
, defaultColor
is returned.key
- an Object
specifying the colordefaultColor
- the color to return if the color specified by key
does not existColor
objectNullPointerException
- if key
or defaultColor
is null
public static Dimension getSafeDimension(Object key, Dimension defaultDimension)
key
is
not a Dimension
, defaultDimension
is returned.key
- an Object
specifying the dimensiondefaultDimension
- the dimension to return if the dimension specified by
key
does not existDimension
objectNullPointerException
- if key
or defaultColor
is null
public static Font getSafeFont(Object key, Font defaultFont)
key
is not a
Font
, defaultFont
is returned.key
- an Object
specifying the fontdefaultFont
- the font to return if the font specified by key
does not existFont
objectNullPointerException
- if key
or defaultFont
is null
public static Icon getSafeIcon(Object key, Icon defaultIcon)
key
is not a
Icon
, defaultIcon
is returned.key
- an Object
specifying the icondefaultIcon
- the icon to return if the icon specified by key
does not existIcon
objectNullPointerException
- if key
or defaultIcon
is null
public static Insets getSafeInsets(Object key, Insets defaultInsets)
key
is not
a Insets
, defaultInsets
is returned.key
- an Object
specifying the insetsdefaultInsets
- the insets to return if the insets specified by
key
does not existInsets
objectNullPointerException
- if key
or defaultInsets
is null
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses