Whole document tree
javax.swing
|
Inner Class Summary | |
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. |
Inner classes inherited from class java.util.Map |
Map.Entry |
Constructor Summary | |
UIDefaults()
Create an empty defaults table. |
|
UIDefaults(Object[] keyValueList)
Create a defaults table initialized with the specified key/value pairs. |
Method Summary | |
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. |
protected void |
firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
Support for reporting bound property changes. |
Object |
get(Object key)
Returns the value for key. |
Border |
getBorder(Object key)
If the value of key 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 . |
Dimension |
getDimension(Object key)
If the value of key 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 . |
Icon |
getIcon(Object key)
If the value of key 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 . |
int |
getInt(Object key)
If the value of key is an Integer return its
integer value, otherwise return 0. |
String |
getString(Object key)
If the value of key is a String return it,
otherwise return null . |
ComponentUI |
getUI(JComponent target)
Creates an ComponentUI implementation for the
specified component. |
Class |
getUIClass(String uiClassID)
Returns the L&F class that renders this component. |
Class |
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 . |
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. |
Methods inherited from class java.util.Hashtable |
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, hashCode, isEmpty, keys, keySet, putAll, rehash, remove, size, toString, values |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public UIDefaults()
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
pairsMethod Detail |
public 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.key
- the desired keykey
UIDefaults.LazyValue
,
UIDefaults.ActiveValue
,
Hashtable.get(java.lang.Object)
public Object put(Object key, Object value)
key
to value
.
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 itvalue
- the new Object
to store as data under
that keyObject
value, or null
putDefaults(java.lang.Object[])
,
Hashtable.put(java.lang.Object, java.lang.Object)
public void putDefaults(Object[] keyValueList)
PropertyChangeEvent
.
The events oldValue and newValue will be null
and its
propertyName
will be "UIDefaults".keyValueList
- an array of key/value pairsput(java.lang.Object, java.lang.Object)
,
Hashtable.put(java.lang.Object, java.lang.Object)
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 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 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 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 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 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 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 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 Class getUIClass(String uiClassID, ClassLoader uiClassLoader)
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 neccessary to call it directly.
uiClassID
- a string containing the class IDuiClassLoader
- the object which will load the classClass.forName(get(uidClassID))
getUI(javax.swing.JComponent)
public Class getUIClass(String uiClassID)
uiClassID
- a string containing the class IDgetUIClass(uiClassID, null)
protected void getUIError(String msg)
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 printgetUI(javax.swing.JComponent)
public ComponentUI getUI(JComponent target)
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 UIComponentUI
objectpublic void addPropertyChangeListener(PropertyChangeListener listener)
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 addedPropertyChangeSupport
public void removePropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener
from the listener list.
This removes a PropertyChangeListener
that was registered
for all properties.listener
- the PropertyChangeListener
to be removedPropertyChangeSupport
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
PropertyChangeEvent
x
listener list isn't empty, then fire a
PropertyChange
event to each listener.propertyName
- the programmatic name of the property
that was changedoldValue
- the old value of the propertynewValue
- the new value of the propertyPropertyChangeSupport
|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-2001 Sun Microsystems, Inc. 901 San Antonio Road
Palo Alto, California, 94303, U.S.A. All Rights Reserved.