public class UIDefaults extends Hashtable<Object,Object>
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 XMLEncoder
.
UIManager
Modifier and Type | Class | Description |
---|---|---|
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. |
static class |
UIDefaults.LazyInputMap |
LazyInputMap will create a InputMap
in its createValue
method. |
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. |
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. |
Constructor | Description |
---|---|
UIDefaults() |
Creates an empty defaults table.
|
UIDefaults(int initialCapacity,
float loadFactor) |
Creates an empty defaults table with the specified initial capacity and
load factor.
|
UIDefaults(Object[] keyValueList) |
Creates a defaults table initialized with the specified
key/value pairs.
|
Modifier and Type | Method | Description |
---|---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener) |
Adds a
PropertyChangeListener to the listener list. |
void |
addResourceBundle(String bundleName) |
Adds a resource bundle to the list of resource bundles that are
searched for localized values.
|
protected void |
firePropertyChange(String propertyName,
Object oldValue,
Object newValue) |
Support for reporting bound property changes.
|
Object |
get(Object key) |
Returns the value for key.
|
Object |
get(Object key,
Locale l) |
Returns the value for key associated with the given locale.
|
boolean |
getBoolean(Object key) |
If the value of
key is boolean, return the
boolean value, otherwise return false. |
boolean |
getBoolean(Object key,
Locale l) |
If the value of
key for the given Locale
is boolean, return the boolean value, otherwise return false. |
Border |
getBorder(Object key) |
If the value of
key is a Border return it,
otherwise return null . |
Border |
getBorder(Object key,
Locale l) |
If the value of
key for the given Locale
is a Border return it, otherwise return null . |
Color |
getColor(Object key) |
If the value of
key is a Color return it,
otherwise return null . |
Color |
getColor(Object key,
Locale l) |
If the value of
key for the given Locale
is a Color return it, otherwise return null . |
Locale |
getDefaultLocale() |
Returns the default locale.
|
Dimension |
getDimension(Object key) |
If the value of
key is a Dimension return it,
otherwise return null . |
Dimension |
getDimension(Object key,
Locale l) |
If the value of
key for the given Locale
is a Dimension return it, otherwise return null . |
Font |
getFont(Object key) |
If the value of
key is a Font return it,
otherwise return null . |
Font |
getFont(Object key,
Locale l) |
If the value of
key for the given Locale
is a Font return it, otherwise return null . |
Icon |
getIcon(Object key) |
If the value of
key is an Icon return it,
otherwise return null . |
Icon |
getIcon(Object key,
Locale l) |
If the value of
key for the given Locale
is an Icon return it, otherwise return null . |
Insets |
getInsets(Object key) |
If the value of
key is an Insets return it,
otherwise return null . |
Insets |
getInsets(Object key,
Locale l) |
If the value of
key for the given Locale
is an Insets return it, otherwise return null . |
int |
getInt(Object key) |
If the value of
key is an Integer return its
integer value, otherwise return 0. |
int |
getInt(Object key,
Locale l) |
If the value of
key for the given Locale
is an Integer return its integer value, otherwise return 0. |
PropertyChangeListener[] |
getPropertyChangeListeners() |
Returns an array of all the
PropertyChangeListener s added
to this UIDefaults with addPropertyChangeListener(). |
String |
getString(Object key) |
If the value of
key is a String return it,
otherwise return null . |
String |
getString(Object key,
Locale l) |
If the value of
key for the given Locale
is a String return it, otherwise return null . |
ComponentUI |
getUI(JComponent target) |
Creates an
ComponentUI implementation for the
specified component. |
Class<? extends ComponentUI> |
getUIClass(String uiClassID) |
Returns the L&F class that renders this component.
|
Class<? extends ComponentUI> |
getUIClass(String uiClassID,
ClassLoader uiClassLoader) |
The value of
get(uidClassID) must be the
String name of a
class that implements the corresponding ComponentUI
class. |
protected void |
getUIError(String msg) |
If
getUI() fails for any reason,
it calls this method before returning null . |
Object |
put(Object key,
Object value) |
Sets the value of
key to value for all locales. |
void |
putDefaults(Object[] keyValueList) |
Puts all of the key/value pairs in the database and
unconditionally generates one
PropertyChangeEvent . |
void |
removePropertyChangeListener(PropertyChangeListener listener) |
Removes a
PropertyChangeListener from the listener list. |
void |
removeResourceBundle(String bundleName) |
Removes a resource bundle from the list of resource bundles that are
searched for localized defaults.
|
void |
setDefaultLocale(Locale l) |
Sets the default locale.
|
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, getOrDefault, hashCode, isEmpty, keys, keySet, merge, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, size, toString, values
public UIDefaults()
public UIDefaults(int initialCapacity, float loadFactor)
initialCapacity
- the initial capacity of the defaults tableloadFactor
- the load factor of the defaults tableHashtable
public UIDefaults(Object[] keyValueList)
Object[] uiDefaults = { "Font", new Font("Dialog", Font.BOLD, 12), "Color", Color.red, "five", new Integer(5) } UIDefaults myDefaults = new UIDefaults(uiDefaults);
keyValueList
- an array of objects containing the key/value
pairspublic Object get(Object key)
UIDefaults.LazyValue
then the real
value is computed with LazyValue.createValue()
,
the table entry is replaced, and the real value is returned.
If the value is an UIDefaults.ActiveValue
the table entry is not replaced - the value is computed
with ActiveValue.createValue()
for each
get()
call.
If the key is not found in the table then it is searched for in the list
of resource bundles maintained by this object. The resource bundles are
searched most recently added first using the locale returned by
getDefaultLocale
. LazyValues
and
ActiveValues
are not supported in the resource bundles.get
in interface Map<Object,Object>
get
in class Hashtable<Object,Object>
key
- the desired keykey
UIDefaults.LazyValue
,
UIDefaults.ActiveValue
,
Hashtable.get(java.lang.Object)
,
getDefaultLocale()
,
addResourceBundle(java.lang.String)
public Object get(Object key, Locale l)
UIDefaults.LazyValue
then the real
value is computed with LazyValue.createValue()
,
the table entry is replaced, and the real value is returned.
If the value is an UIDefaults.ActiveValue
the table entry is not replaced - the value is computed
with ActiveValue.createValue()
for each
get()
call.
If the key is not found in the table then it is searched for in the list
of resource bundles maintained by this object. The resource bundles are
searched most recently added first using the given locale.
LazyValues
and ActiveValues
are not supported
in the resource bundles.key
- the desired keyl
- the desired locale
key
UIDefaults.LazyValue
,
UIDefaults.ActiveValue
,
Hashtable.get(java.lang.Object)
,
addResourceBundle(java.lang.String)
public Object put(Object key, Object value)
key
to value
for all locales.
If key
is a string and the new value isn't
equal to the old one, fire a PropertyChangeEvent
.
If value is null
, the key is removed from the table.put
in interface Map<Object,Object>
put
in class Hashtable<Object,Object>
key
- the unique Object
who's value will be used
to retrieve the data value associated with itvalue
- the new Object
to store as data under
that keyObject
value, or null
putDefaults(java.lang.Object[])
,
Hashtable.put(K, V)
public void putDefaults(Object[] keyValueList)
PropertyChangeEvent
.
The events oldValue and newValue will be null
and its
propertyName
will be "UIDefaults". The key/value pairs are
added for all locales.keyValueList
- an array of key/value pairsput(java.lang.Object, java.lang.Object)
,
Hashtable.put(K, V)
public Font getFont(Object key)
key
is a Font
return it,
otherwise return null
.key
- the desired keykey
is a Font
,
return the Font
object; otherwise return
null
public Font getFont(Object key, Locale l)
key
for the given Locale
is a Font
return it, otherwise return null
.key
- the desired keyl
- the desired localekey
and Locale
is a Font
,
return the Font
object; otherwise return
null
public Color getColor(Object key)
key
is a Color
return it,
otherwise return null
.key
- the desired keykey
is a Color
,
return the Color
object; otherwise return
null
public Color getColor(Object key, Locale l)
key
for the given Locale
is a Color
return it, otherwise return null
.key
- the desired keyl
- the desired localekey
and Locale
is a Color
,
return the Color
object; otherwise return
null
public Icon getIcon(Object key)
key
is an Icon
return it,
otherwise return null
.key
- the desired keykey
is an Icon
,
return the Icon
object; otherwise return
null
public Icon getIcon(Object key, Locale l)
key
for the given Locale
is an Icon
return it, otherwise return null
.key
- the desired keyl
- the desired localekey
and Locale
is an Icon
,
return the Icon
object; otherwise return
null
public Border getBorder(Object key)
key
is a Border
return it,
otherwise return null
.key
- the desired keykey
is a Border
,
return the Border
object; otherwise return
null
public Border getBorder(Object key, Locale l)
key
for the given Locale
is a Border
return it, otherwise return null
.key
- the desired keyl
- the desired localekey
and Locale
is a Border
,
return the Border
object; otherwise return
null
public String getString(Object key)
key
is a String
return it,
otherwise return null
.key
- the desired keykey
is a String
,
return the String
object; otherwise return
null
public String getString(Object key, Locale l)
key
for the given Locale
is a String
return it, otherwise return null
.key
- the desired keyl
- the desired Locale
key
for the given
Locale
is a String
,
return the String
object; otherwise return
null
public int getInt(Object key)
key
is an Integer
return its
integer value, otherwise return 0.key
- the desired keykey
is an Integer
,
return its value, otherwise return 0public int getInt(Object key, Locale l)
key
for the given Locale
is an Integer
return its integer value, otherwise return 0.key
- the desired keyl
- the desired localekey
and Locale
is an Integer
,
return its value, otherwise return 0public boolean getBoolean(Object key)
key
is boolean, return the
boolean value, otherwise return false.key
- an Object
specifying the key for the desired boolean valuekey
is boolean, return the
boolean value, otherwise return false.public boolean getBoolean(Object key, Locale l)
key
for the given Locale
is boolean, return the boolean value, otherwise return false.key
- an Object
specifying the key for the desired boolean valuel
- the desired localekey
and Locale
is boolean, return the
boolean value, otherwise return false.public Insets getInsets(Object key)
key
is an Insets
return it,
otherwise return null
.key
- the desired keykey
is an Insets
,
return the Insets
object; otherwise return
null
public Insets getInsets(Object key, Locale l)
key
for the given Locale
is an Insets
return it, otherwise return null
.key
- the desired keyl
- the desired localekey
and Locale
is an Insets
,
return the Insets
object; otherwise return
null
public Dimension getDimension(Object key)
key
is a Dimension
return it,
otherwise return null
.key
- the desired keykey
is a Dimension
,
return the Dimension
object; otherwise return
null
public Dimension getDimension(Object key, Locale l)
key
for the given Locale
is a Dimension
return it, otherwise return null
.key
- the desired keyl
- the desired localekey
and Locale
is a Dimension
,
return the Dimension
object; otherwise return
null
public Class<? extends ComponentUI> getUIClass(String uiClassID,