Top Description Inners Fields Constructors Methods
javax.swing

public Class UIDefaults

extends Hashtable<Object, Object>
Class Inheritance
Known Direct Subclasses
javax.swing.plaf.multi.MultiUIDefaults, javax.swing.MultiUIDefaults
Annotations
@SuppressWarnings:serial
Imports
javax.swing.plaf.ComponentUI, javax.swing.border.*, javax.swing.event.SwingPropertyChangeSupport, java.io.IOException, .InputStream, .PrintWriter, .StringWriter, .UncheckedIOException, java.lang.reflect.*, java.util.HashMap, .Map, .Enumeration, .Hashtable, .ResourceBundle, .Locale, .Vector, .MissingResourceException, java.awt.Font, .Color, .Insets, .Dimension, java.beans.PropertyChangeListener, java.security.AccessController, .AccessControlContext, .PrivilegedAction, sun.reflect.misc.MethodUtil, .ReflectUtil, sun.swing.SwingAccessor, .SwingUtilities2

A table of defaults for Swing components. Applications can set/get default values via the UIManager.

Warning

Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Author
Hans Muller
Since
1.2
See Also
UIManager

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
UIDefaults.ActiveValue

This class enables one to store an entry in the defaults table that's constructed each time it's looked up with one of the getXXX(key) methods.

public static class
UIDefaults.LazyInputMap

LazyInputMap will create a InputMap in its createValue method.

public static interface
UIDefaults.LazyValue

This class enables one to store an entry in the defaults table that isn't constructed until the first time it's looked up with one of the getXXX(key) methods.

public static class
UIDefaults.ProxyLazyValue

This class provides an implementation of LazyValue which can be used to delay loading of the Class for the instance to be created.

private static class
UIDefaults.TextAndMnemonicHashMap

TextAndMnemonicHashMap stores swing resource strings.

Field Summary

Modifier and TypeField and Description
private SwingPropertyChangeSupport
private Locale
private static final Object
private Vector<String>
private Map<Locale, Map<String, Object>>
resourceCache

Maps from a Locale to a cached Map of the ResourceBundle.

Constructor Summary

AccessConstructor and Description
public
UIDefaults()

Creates an empty defaults table.

public
UIDefaults(int
the initial capacity of the defaults table
initialCapacity
,
float
the load factor of the defaults table
loadFactor
)

Creates an empty defaults table with the specified initial capacity and load factor.

public
UIDefaults(Object[]
an array of objects containing the key/value pairs
keyValueList
)

Creates a defaults table initialized with the specified key/value pairs.

Method Summary

Modifier and TypeMethod and Description
private synchronized void
addInternalBundle(final String
the base name of the resource bundle to be added
bundleName
)

This methods should be used to register internal resource bundles from the java.desktop module.

public synchronized void
addPropertyChangeListener(PropertyChangeListener
the PropertyChangeListener to be added
listener
)

Adds a PropertyChangeListener to the listener list.

public synchronized void
addResourceBundle(final String
the base name of the resource bundle to be added
bundleName
)

Adds a resource bundle to the list of resource bundles that are searched for localized values.

protected void
firePropertyChange(String
the programmatic name of the property that was changed
propertyName
,
Object
the old value of the property
oldValue
,
Object
the new value of the property
newValue
)

Support for reporting bound property changes.

public Object

Returns:

the value for key
get
(Object
the desired key
key
)

Overrides java.util.Hashtable.get.

Implements java.util.Map.get.

Returns the value for key.
public Object

Returns:

the value for key
get
(Object
the desired key
key
,
Locale
the desired locale
l
)

Returns the value for key associated with the given locale.

public boolean

Returns:

if the value of key is boolean, return the boolean value, otherwise return false.
getBoolean
(Object
an Object specifying the key for the desired boolean value
key
)

If the value of key is boolean, return the boolean value, otherwise return false.

public boolean

Returns:

if the value for key and Locale is boolean, return the boolean value, otherwise return false.
getBoolean
(Object
an Object specifying the key for the desired boolean value
key
,
Locale
the desired locale
l
)

If the value of key for the given Locale is boolean, return the boolean value, otherwise return false.

public Border

Returns:

if the value for key is a Border, return the Border object; otherwise return null
getBorder
(Object
the desired key
key
)

If the value of key is a Border return it, otherwise return null.

public Border

Returns:

if the value for key and Locale is a Border, return the Border object; otherwise return null
getBorder
(Object
the desired key
key
,
Locale
the desired locale
l
)

If the value of key for the given Locale is a Border return it, otherwise return null.

public Color

Returns:

if the value for key is a Color, return the Color object; otherwise return null
getColor
(Object
the desired key
key
)

If the value of key is a Color return it, otherwise return null.

public Color

Returns:

if the value for key and Locale is a Color, return the Color object; otherwise return null
getColor
(Object
the desired key
key
,
Locale
the desired locale
l
)

If the value of key for the given Locale is a Color return it, otherwise return null.

public Locale

Returns:

the default locale
getDefaultLocale
()

Returns the default locale.

public Dimension

Returns:

if the value for key is a Dimension, return the Dimension object; otherwise return null
getDimension
(Object
the desired key
key
)

If the value of key is a Dimension return it, otherwise return null.

public Dimension

Returns:

if the value for key and Locale is a Dimension, return the Dimension object; otherwise return null
getDimension
(Object
the desired key
key
,
Locale
the desired locale
l
)

If the value of key for the given Locale is a Dimension return it, otherwise return null.

public Font

Returns:

if the value for key is a Font, return the Font object; otherwise return null
getFont
(Object
the desired key
key
)

If the value of key is a Font return it, otherwise return null.

public Font

Returns:

if the value for key and Locale is a Font, return the Font object; otherwise return null
getFont
(Object
the desired key
key
,
Locale
the desired locale
l
)

If the value of key for the given Locale is a Font return it, otherwise return null.

private Object
getFromHashtable(final Object key)

Looks up the given key in our Hashtable and resolves LazyValues or ActiveValues.

private Object
getFromResourceBundle(Object key, Locale l)

Looks up given key in our resource bundles.

public Icon

Returns:

if the value for key is an Icon, return the Icon object; otherwise return null
getIcon
(Object
the desired key
key
)

If the value of key is an Icon return it, otherwise return null.

public Icon

Returns:

if the value for key and Locale is an Icon, return the Icon object; otherwise return null
getIcon
(Object
the desired key
key
,
Locale
the desired locale
l
)

If the value of key for the given Locale is an Icon return it, otherwise return null.

public Insets

Returns:

if the value for key is an Insets, return the Insets object; otherwise return null
getInsets
(Object
the desired key
key
)

If the value of key is an Insets return it, otherwise return null.

public Insets

Returns:

if the value for key and Locale is an Insets, return the Insets object; otherwise return null
getInsets
(Object
the desired key
key
,
Locale
the desired locale
l
)

If the value of key for the given Locale is an Insets return it, otherwise return null.

public int

Returns:

if the value for key is an Integer, return its value, otherwise return 0
getInt
(Object
the desired key
key
)

If the value of key is an Integer return its integer value, otherwise return 0.

public int

Returns:

if the value for key and Locale is an Integer, return its value, otherwise return 0
getInt
(Object
the desired key
key
,
Locale
the desired locale
l
)

If the value of key for the given Locale is an Integer return its integer value, otherwise return 0.

public synchronized PropertyChangeListener[]

Returns:

all of the PropertyChangeListeners added or an empty array if no listeners have been added
getPropertyChangeListeners
()

Returns an array of all the PropertyChangeListeners added to this UIDefaults with addPropertyChangeListener().

private Map<String, Object>
getResourceCache(Locale l)

Returns a Map of the known resources for the given locale.

public String

Returns:

if the value for key is a String, return the String object; otherwise return null
getString
(Object
the desired key
key
)

If the value of key is a String return it, otherwise return null.

public String

Returns:

if the value for key for the given Locale is a String, return the String object; otherwise return null
getString
(Object
the desired key
key
,
Locale
the desired Locale
l
)

If the value of key for the given Locale is a String return it, otherwise return null.

public ComponentUI

Returns:

the ComponentUI object
getUI
(JComponent
the JComponent which needs a UI
target
)

Creates an ComponentUI implementation for the specified component.

public Class<? extends ComponentUI>

Returns:

the value of Class.forName(get(uidClassID))
getUIClass
(String
a string containing the class ID
uiClassID
,
ClassLoader
the object which will load the class
uiClassLoader
)

The value of get(uidClassID) must be the String name of a class that implements the corresponding ComponentUI class.

public Class<? extends ComponentUI>

Returns:

the Class object returned by getUIClass(uiClassID, null)
getUIClass
(String
a string containing the class ID
uiClassID
)

Returns the L&F class that renders this component.

protected void
getUIError(String
message string to print
msg
)

If getUI() fails for any reason, it calls this method before returning null.

private static boolean
public Object

Returns:

the previous Object value, or null
put
(Object
the unique Object who's value will be used to retrieve the data value associated with it
key
,
Object
the new Object to store as data under that key
value
)

Overrides java.util.Hashtable.put.

Implements java.util.Map.put.

Sets the value of key to value for all locales.
public void
putDefaults(Object[]
an array of key/value pairs
keyValueList
)

Puts all of the key/value pairs in the database and unconditionally generates one PropertyChangeEvent.

public synchronized void
removePropertyChangeListener(PropertyChangeListener
the PropertyChangeListener to be removed
listener
)

Removes a PropertyChangeListener from the listener list.

public synchronized void
removeResourceBundle(String
the base name of the resource bundle to be removed
bundleName
)

Removes a resource bundle from the list of resource bundles that are searched for localized defaults.

public void
setDefaultLocale(Locale
the new default locale
l
)

Sets the default locale.

Inherited from java.util.Hashtable:
clearclonecomputecomputeIfAbsentcomputeIfPresentcontainscontainsKeycontainsValueelementsentrySetequalsforEachgetOrDefaulthashCodeisEmptykeyskeySetmergeputAllputIfAbsentrehashremoveremovereplacereplacereplaceAllsizetoStringvalues