Class UIManagerExt
- java.lang.Object
-
- org.jdesktop.swingx.plaf.UIManagerExt
-
public class UIManagerExt extends java.lang.ObjectA utility class for obtaining configuration properties from theUIDefaults. This class handles SwingX-specific L&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
getSafeXXXmethods are designed for use withLookAndFeelAddons. Any addon that attempts to obtain a property defined in the defaults (available fromUIManager.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 aUIResource.Support for New Types
UIManagerExtsupports the retrieval of newUIResourcetypes. There is agetXXXmethod for everyUIResourcesubtype in theorg.jdesktop.swingx.plafpackage.Support for Dynamic Localization
UIManagerExtenables dynamic localization by supportingResourceBundles. The UIDefaults.addResourceBundle(String) allows resource bundles to be added to theUIDefaults. 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,UIManagerExtdefines methods to add and remove resource bundles. These are the only methods that SwingX classes should use when adding resource bundles to the defaults. SinceUIManagerExtis maintaining the bundles, any localizedStrings must be retrieved from thegetStringmethods in this class.Support for Non-
StringLocalization ValuesAll methods work by first determining if the value is present
UIDefaults. If the value is not present, then the installedResourceBundles are queried.UIManagerExtwill attempt to convert any returned value to the appropriate type. For instance,getIntusesInteger.decodeto convertStrings returned from the bundle intoints.- See Also:
UIManager,UIDefaults
- Support for the safe creation of
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classUIManagerExt.UIDefaultsExtUsed to replicate the resource bundle behavior from theUIDefaults.
-
Field Summary
Fields Modifier and Type Field Description private static UIManagerExt.UIDefaultsExtuiDefaultsExt
-
Constructor Summary
Constructors Modifier Constructor Description privateUIManagerExt()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddResourceBundle(java.lang.String bundleName)Adds a resource bundle to the list of resource bundles that are searched for localized values.static booleangetBoolean(java.lang.Object key)Returns an Boolean from the defaults.static booleangetBoolean(java.lang.Object key, java.util.Locale l)Returns an Boolean from the defaults.static java.awt.ColorgetColor(java.lang.Object key)Returns a color from the defaults.static java.awt.ColorgetColor(java.lang.Object key, java.util.Locale l)Returns a color from the defaults.static intgetInt(java.lang.Object key)Returns an integer from the defaults.static intgetInt(java.lang.Object key, java.util.Locale l)Returns an integer from the defaults.static Painter<?>getPainter(java.lang.Object key)Returns a painter from the defaults.static Painter<?>getPainter(java.lang.Object key, java.util.Locale l)Returns a painter from the defaults that is appropriate for the given locale.static javax.swing.border.BordergetSafeBorder(java.lang.Object key, javax.swing.border.Border defaultBorder)Returns a border from the defaults.static java.awt.ColorgetSafeColor(java.lang.Object key, java.awt.Color defaultColor)Returns a color from the defaults.static java.awt.DimensiongetSafeDimension(java.lang.Object key, java.awt.Dimension defaultDimension)Returns a dimension from the defaults.static java.awt.FontgetSafeFont(java.lang.Object key, java.awt.Font defaultFont)Returns a font from the defaults.static javax.swing.IcongetSafeIcon(java.lang.Object key, javax.swing.Icon defaultIcon)Returns an icon from the defaults.static java.awt.InsetsgetSafeInsets(java.lang.Object key, java.awt.Insets defaultInsets)Returns an insets from the defaults.static java.awt.ShapegetShape(java.lang.Object key)Returns a shape from the defaults.static java.awt.ShapegetShape(java.lang.Object key, java.util.Locale l)Returns a shape from the defaults that is appropriate for the given locale.static java.lang.StringgetString(java.lang.Object key)Returns a string from the defaults.static java.lang.StringgetString(java.lang.Object key, java.util.Locale l)Returns a string from the defaults.static voidremoveResourceBundle(java.lang.String bundleName)Removes a resource bundle from the list of resource bundles that are searched for localized defaults.
-
-
-
Field Detail
-
uiDefaultsExt
private static UIManagerExt.UIDefaultsExt uiDefaultsExt
-
-
Method Detail
-
addResourceBundle
public static void addResourceBundle(java.lang.String bundleName)
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:
ResourceBundle,removeResourceBundle(java.lang.String)
-
removeResourceBundle
public static void removeResourceBundle(java.lang.String bundleName)
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:
ResourceBundle,addResourceBundle(java.lang.String)
-
getString
public static java.lang.String getString(java.lang.Object key)
Returns a string from the defaults. If the value forkeyis not aString,nullis returned.- Parameters:
key- anObjectspecifying the string- Returns:
- the
Stringobject - Throws:
java.lang.NullPointerException- ifkeyisnull
-
getString
public static java.lang.String getString(java.lang.Object key, java.util.Locale l)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:
java.lang.NullPointerException- ifkeyisnull
-
getInt
public static int getInt(java.lang.Object key)
Returns an integer from the defaults. If the value forkeyis not anint,0is returned.- Parameters:
key- anObjectspecifying the integer- Returns:
- the
int - Throws:
java.lang.NullPointerException- ifkeyisnull
-
getInt
public static int getInt(java.lang.Object key, java.util.Locale l)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:
java.lang.NullPointerException- ifkeyisnull
-
getBoolean
public static boolean getBoolean(java.lang.Object key)
Returns an Boolean from the defaults. If the value forkeyis not aboolean,falseis returned.- Parameters:
key- anObjectspecifying the Boolean- Returns:
- the
boolean - Throws:
java.lang.NullPointerException- ifkeyisnull
-
getBoolean
public static boolean getBoolean(java.lang.Object key, java.util.Locale l)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:
java.lang.NullPointerException- ifkeyisnull
-
getColor
public static java.awt.Color getColor(java.lang.Object key)
Returns a color from the defaults. If the value forkeyis not aColor,nullis returned.- Parameters:
key- anObjectspecifying the color- Returns:
- the
Colorobject - Throws:
java.lang.NullPointerException- ifkeyisnull
-
getColor
public static java.awt.Color getColor(java.lang.Object key, java.util.Locale l)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:
java.lang.NullPointerException- ifkeyisnull
-
getShape
public static java.awt.Shape getShape(java.lang.Object key)
Returns a shape from the defaults. If the value forkeyis not aShape,nullis returned.- Parameters:
key- anObjectspecifying the shape- Returns:
- the
Shapeobject - Throws:
java.lang.NullPointerException- ifkeyisnull
-
getShape
public static java.awt.Shape getShape(java.lang.Object key, java.util.Locale l)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:
java.lang.NullPointerException- ifkeyisnull
-
getPainter
public static Painter<?> getPainter(java.lang.Object key)
Returns a painter from the defaults. If the value forkeyis not aPainter,nullis returned.- Parameters:
key- anObjectspecifying the painter- Returns:
- the
Painterobject - Throws:
java.lang.NullPointerException- ifkeyisnull
-
getPainter
public static Painter<?> getPainter(java.lang.Object key, java.util.Locale l)
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:
java.lang.NullPointerException- ifkeyisnull
-
getSafeBorder
public static javax.swing.border.Border getSafeBorder(java.lang.Object key, javax.swing.border.Border defaultBorder)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:
java.lang.NullPointerException- ifkeyordefaultBorderisnull
-
getSafeColor
public static java.awt.Color getSafeColor(java.lang.Object key, java.awt.Color defaultColor)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:
java.lang.NullPointerException- ifkeyordefaultColorisnull
-
getSafeDimension
public static java.awt.Dimension getSafeDimension(java.lang.Object key, java.awt.Dimension defaultDimension)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:
java.lang.NullPointerException- ifkeyordefaultColorisnull
-
getSafeFont
public static java.awt.Font getSafeFont(java.lang.Object key, java.awt.Font defaultFont)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:
java.lang.NullPointerException- ifkeyordefaultFontisnull
-
getSafeIcon
public static javax.swing.Icon getSafeIcon(java.lang.Object key, javax.swing.Icon defaultIcon)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:
java.lang.NullPointerException- ifkeyordefaultIconisnull
-
getSafeInsets
public static java.awt.Insets getSafeInsets(java.lang.Object key, java.awt.Insets defaultInsets)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:
java.lang.NullPointerException- ifkeyordefaultInsetsisnull
-
-