public class PropDefaults
extends java.util.Properties
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 Swing1.0 applications. It will not be possible to load serialized Swing1.0 objects with future releases of Swing. The JDK1.2 release of Swing will be the compatibility baseline for the serialized form of Swing objects.
PropManager
,
Serialized FormModifier and Type | Class and Description |
---|---|
static interface |
PropDefaults.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 interface |
PropDefaults.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. |
Constructor and Description |
---|
PropDefaults()
Create an empty defaults table.
|
PropDefaults(java.lang.Object[] keyValueList)
Create a defaults table initialized with the specified
key/value pairs.
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list.
|
protected void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
Support for reporting bound property changes.
|
java.lang.Object |
get(java.lang.Object key) |
boolean |
getBoolean(java.lang.Object key)
If the value of
key is a boolean return its
integer value, otherwise return false. |
java.awt.Color |
getColor(java.lang.Object key)
If the value of
key is a Color return it, otherwise
return null. |
double |
getDouble(java.lang.Object key)
If the value of
key is a Double return its
double value, otherwise return 0.0. |
float |
getFloat(java.lang.Object key)
If the value of
key is a Float return its
float value, otherwise return 0.0F. |
java.awt.Font |
getFont(java.lang.Object key)
If the value of
key is a Font return it, otherwise
return null. |
javax.swing.Icon |
getIcon(java.lang.Object key)
If the value of
key is an Icon return it, otherwise
return null. |
int |
getInt(java.lang.Object key)
If the value of
key is a Integer return its
integer value, otherwise return 0. |
long |
getLong(java.lang.Object key)
If the value of
key is a Long return its
long value, otherwise return 0. |
java.lang.Class |
getPropClass(java.lang.String propClassID) |
java.lang.Class |
getPropClass(java.lang.String propClassID,
java.lang.ClassLoader propClassLoader)
The value of get(propClassID) must be the String name of a
class that implements the corresponding class.
|
java.lang.String |
getString(java.lang.Object key)
If the value of
key is a String return it, otherwise
return key if it is a String else null. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Set the value of
key to value . |
void |
putDefaults(java.lang.Object[] keyValueList)
Put all of the key/value pairs in the database and
unconditionally generate one PropertyChangeEvent.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list.
|
getProperty, getProperty, list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames
public PropDefaults()
public PropDefaults(java.lang.Object[] keyValueList)
Object[] propDefaults = { "Font", new Font("Dialog", Font.BOLD, 12), "Color", Color.red, "five", new Integer(5) } PropDefaults myDefaults = new PropDefaults(propDefaults);
public java.lang.Object get(java.lang.Object key)
get
in interface java.util.Map<java.lang.Object,java.lang.Object>
get
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
public java.lang.Object put(java.lang.Object key, java.lang.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.put
in interface java.util.Map<java.lang.Object,java.lang.Object>
put
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
putDefaults(java.lang.Object[])
,
Hashtable.put(K, V)
public void putDefaults(java.lang.Object[] keyValueList)
put(java.lang.Object, java.lang.Object)
,
Hashtable.put(K, V)
public java.awt.Font getFont(java.lang.Object key)
key
is a Font return it, otherwise
return null.public java.awt.Color getColor(java.lang.Object key)
key
is a Color return it, otherwise
return null.public javax.swing.Icon getIcon(java.lang.Object key)
key
is an Icon return it, otherwise
return null.public java.lang.String getString(java.lang.Object key)
key
is a String return it, otherwise
return key if it is a String else null.public boolean getBoolean(java.lang.Object key)
key
is a boolean return its
integer value, otherwise return false.public int getInt(java.lang.Object key)
key
is a Integer return its
integer value, otherwise return 0.public long getLong(java.lang.Object key)
key
is a Long return its
long value, otherwise return 0.public float getFloat(java.lang.Object key)
key
is a Float return its
float value, otherwise return 0.0F.public double getDouble(java.lang.Object key)
key
is a Double return its
double value, otherwise return 0.0.public java.lang.Class getPropClass(java.lang.String propClassID, java.lang.ClassLoader propClassLoader)
propClassLoader.loadClass()
if a non null
class loader is provided, classForName()
otherwise.
If a mapping for propClassID exists or if the specified class can't be found, return null.
This method is used by getClassById
, it's usually
not neccessary to call it directly.
Class.forName(get(ClassID))
.#getClassById
public java.lang.Class getPropClass(java.lang.String propClassID)
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
A PropertyChangeEvent will get fired whenever a default is changed.
listener
- The PropertyChangeListener to be addedPropertyChangeSupport
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The PropertyChangeListener to be removedPropertyChangeSupport
protected void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
propertyName
- The programmatic name of the property that was changed.oldValue
- The old value of the property.newValue
- The new value of the property.PropertyChangeSupport