java.lang.Object | |||
↳ | java.util.Dictionary<K, V> | ||
↳ | java.util.Hashtable<K, V> | ||
↳ | javax.swing.UIDefaults |
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 JavaBeansTM
has been added to the java.beans
package.
Please see XMLEncoder
.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
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. |
||||||||||
UIDefaults.LazyInputMap | LazyInputMap will create a InputMap
in its createValue
method. |
||||||||||
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. |
||||||||||
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. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates an empty defaults table.
| |||||||||||
Creates an empty defaults table with the specified initial capacity and
load factor.
| |||||||||||
Creates a defaults table initialized with the specified
key/value pairs.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds a
PropertyChangeListener to the listener list. | |||||||||||
Adds a resource bundle to the list of resource bundles that are
searched for localized values.
| |||||||||||
Returns the value for key associated with the given locale.
| |||||||||||
Returns the value for key.
| |||||||||||
If the value of
key for the given Locale
is boolean, return the boolean value, otherwise return false. | |||||||||||
If the value of
key is boolean, return the
boolean value, otherwise return false. | |||||||||||
If the value of
key is a Border return it,
otherwise return null . | |||||||||||
If the value of
key for the given Locale
is a Border return it, otherwise return null . | |||||||||||
If the value of
key is a Color return it,
otherwise return null . | |||||||||||
If the value of
key for the given Locale
is a Color return it, otherwise return null . | |||||||||||
Returns the default locale.
| |||||||||||
If the value of
key for the given Locale
is a Dimension return it, otherwise return null . | |||||||||||
If the value of
key is a Dimension return it,
otherwise return null . | |||||||||||
If the value of
key for the given Locale
is a Font return it, otherwise return null . | |||||||||||
If the value of
key is a Font return it,
otherwise return null . | |||||||||||
If the value of
key for the given Locale
is an Icon return it, otherwise return null . | |||||||||||
If the value of
key is an Icon return it,
otherwise return null . | |||||||||||
If the value of
key is an Insets return it,
otherwise return null . | |||||||||||
If the value of
key for the given Locale
is an Insets return it, otherwise return null . | |||||||||||
If the value of
key is an Integer return its
integer value, otherwise return 0. | |||||||||||
If the value of
key for the given Locale
is an Integer return its integer value, otherwise return 0. | |||||||||||
Returns an array of all the
PropertyChangeListener s added
to this UIDefaults with addPropertyChangeListener(). | |||||||||||
If the value of
key is a String return it,
otherwise return null . | |||||||||||
If the value of
key for the given Locale
is a String return it, otherwise return null . | |||||||||||
Creates an
ComponentUI implementation for the
specified component. | |||||||||||
The value of
get(uidClassID) must be the
String name of a
class that implements the corresponding ComponentUI
class. | |||||||||||
Returns the L&F class that renders this component.
| |||||||||||
Sets the value of
key to value for all locales. | |||||||||||
Puts all of the key/value pairs in the database and
unconditionally generates one
PropertyChangeEvent . | |||||||||||
Removes a
PropertyChangeListener from the listener list. | |||||||||||
Removes a resource bundle from the list of resource bundles that are
searched for localized defaults.
| |||||||||||
Sets the default locale.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Support for reporting bound property changes.
| |||||||||||
If
getUI() fails for any reason,
it calls this method before returning null . |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() |
Creates an empty defaults table.
Creates an empty defaults table with the specified initial capacity and load factor.
initialCapacity | the initial capacity of the defaults table |
---|---|
loadFactor | the load factor of the defaults table |
Creates a defaults table initialized with the specified key/value pairs. For example:
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 pairs |
---|
Adds a PropertyChangeListener
to the listener list.
The listener is registered for all properties.
A PropertyChangeEvent
will get fired whenever a default
is changed.
listener | the PropertyChangeListener to be added |
---|
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.
bundleName | the base name of the resource bundle to be added |
---|
Returns the value for key associated with the given locale.
If the value is a 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 key |
---|---|
l | the desired locale |
key
Returns the value for key. If the value is a
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.
key | the desired key |
---|
key
If the value of key
for the given Locale
is boolean, return the boolean value, otherwise return false.
key | an Object specifying the key for the desired boolean value |
---|---|
l | the desired locale |
key
and Locale
is boolean, return the
boolean value, otherwise return false.If the value of key
is boolean, return the
boolean value, otherwise return false.
key | an Object specifying the key for the desired boolean value |
---|
key
is boolean, return the
boolean value, otherwise return false.If the value of key
is a Border
return it,
otherwise return null
.
key | the desired key |
---|
key
is a Border
,
return the Border
object; otherwise return
null
If the value of key
for the given Locale
is a Border
return it, otherwise return null
.
key | the desired key |
---|---|
l | the desired locale |
key
and Locale
is a Border
,
return the Border
object; otherwise return
null
If the value of key
is a Color
return it,
otherwise return null
.
key | the desired key |
---|
key
is a Color
,
return the Color
object; otherwise return
null
If the value of key
for the given Locale
is a Color
return it, otherwise return null
.
key | the desired key |
---|---|
l | the desired locale |
key
and Locale
is a Color
,
return the Color
object; otherwise return
null
Returns the default locale. The default locale is used in retrieving
localized values via get
methods that do not take a
locale argument. As of release 1.4, Swing UI objects should retrieve
localized values using the locale of their component rather than the
default locale. The default locale exists to provide compatibility with
pre 1.4 behaviour.
If the value of key
for the given Locale
is a Dimension
return it, otherwise return null
.
key | the desired key |
---|---|
l | the desired locale |
key
and Locale
is a Dimension
,
return the Dimension
object; otherwise return
null
If the value of key
is a Dimension
return it,
otherwise return null
.
key | the desired key |
---|
key
is a Dimension
,
return the Dimension
object; otherwise return
null
If the value of key
for the given Locale
is a Font
return it, otherwise return null
.
key | the desired key |
---|---|
l | the desired locale |
key
and Locale
is a Font
,
return the Font
object; otherwise return
null
If the value of key
is a Font
return it,
otherwise return null
.
key | the desired key |
---|
key
is a Font
,
return the Font
object; otherwise return
null
If the value of key
for the given Locale
is an Icon
return it, otherwise return null
.
key | the desired key |
---|---|
l | the desired locale |
key
and Locale
is an Icon
,
return the Icon
object; otherwise return
null
If the value of key
is an Icon
return it,
otherwise return null
.
key | the desired key |
---|
key
is an Icon
,
return the Icon
object; otherwise return
null
If the value of key
is an Insets
return it,
otherwise return null
.
key | the desired key |
---|
key
is an Insets
,
return the Insets
object; otherwise return
null
If the value of key
for the given Locale
is an Insets
return it, otherwise return null
.
key | the desired key |
---|---|
l | the desired locale |
key
and Locale
is an Insets
,
return the Insets
object; otherwise return
null
If the value of key
is an Integer
return its
integer value, otherwise return 0.
key | the desired key |
---|
key
is an Integer
,
return its value, otherwise return 0
If the value of key
for the given Locale
is an Integer
return its integer value, otherwise return 0.
key | the desired key |
---|---|
l | the desired locale |
key
and Locale
is an Integer
,
return its value, otherwise return 0Returns an array of all the PropertyChangeListener
s added
to this UIDefaults with addPropertyChangeListener().
PropertyChangeListener
s added or an empty
array if no listeners have been addedIf the value of key
is a String
return it,
otherwise return null
.
key | the desired key |
---|
key
is a String
,
return the String
object; otherwise return
null
If the value of key
for the given Locale
is a String
return it, otherwise return null
.
key | the desired key |
---|---|
l | the desired Locale |
key
for the given
Locale
is a String
,
return the String
object; otherwise return
null
Creates an ComponentUI
implementation for the
specified component. In other words create the look
and feel specific delegate object for target
.
This is done in two steps:
ComponentUI
implementation
class under the value returned by target.getUIClassID()
.
createUI()
method to construct a look and feel delegate.
target | the JComponent which needs a UI |
---|
ComponentUI
object
The value of get(uidClassID)
must be the
String
name of a
class that implements the corresponding ComponentUI
class. If the class hasn't been loaded before, this method looks
up the class with uiClassLoader.loadClass()
if a non
null
class loader is provided, classForName()
otherwise.
If a mapping for uiClassID
exists or if the specified
class can't be found, return null
.
This method is used by getUI
, it's usually
not necessary to call it directly.
uiClassID | a string containing the class ID |
---|---|
uiClassLoader | the object which will load the class |
Class.forName(get(uidClassID))
Returns the L&F class that renders this component.
uiClassID | a string containing the class ID |
---|
getUIClass(uiClassID, null)
Sets the value of 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.
key | the unique Object who's value will be used
to retrieve the data value associated with it |
---|---|
value | the new Object to store as data under
that key |
Object
value, or null
Puts all of the key/value pairs in the database and
unconditionally generates one 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 pairs |
---|
Removes a PropertyChangeListener
from the listener list.
This removes a PropertyChangeListener
that was registered
for all properties.
listener | the PropertyChangeListener to be removed |
---|
Removes a resource bundle from the list of resource bundles that are searched for localized defaults.
bundleName | the base name of the resource bundle to be removed |
---|
Sets the default locale. The default locale is used in retrieving
localized values via get
methods that do not take a
locale argument. As of release 1.4, Swing UI objects should retrieve
localized values using the locale of their component rather than the
default locale. The default locale exists to provide compatibility with
pre 1.4 behaviour.
l | the new default locale |
---|
Support for reporting bound property changes. If oldValue and
newValue are not equal and the PropertyChangeEvent
x
listener list isn't empty, then fire a
PropertyChange
event to each listener.
propertyName | the programmatic name of the property that was changed |
---|---|
oldValue | the old value of the property |
newValue | the new value of the property |
If getUI()
fails for any reason,
it calls this method before returning null
.
Subclasses may choose to do more or less here.
msg | message string to print |
---|