Home » openjdk-7 » javax » swing » [javadoc | source]
javax.swing
public class: UIDefaults [javadoc | source]
java.lang.Object
   java.util.Dictionary<K, V>
      java.util.Hashtable<Object, Object>
         javax.swing.UIDefaults

All Implemented Interfaces:
    Cloneable, Map, java$io$Serializable

Direct Known Subclasses:
    BasicDefaults, MultiUIDefaults, MultiUIDefaults

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 java.beans.XMLEncoder .

Nested Class Summary:
public 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. Lazy values are useful for defaults that are expensive to construct or are seldom retrieved. The first time a LazyValue is retrieved its "real value" is computed by calling LazyValue.createValue() and the real value is used to replace the LazyValue in the UIDefaults table. Subsequent lookups for the same key return the real value. Here's an example of a LazyValue that constructs a Border:
 Object borderLazyValue = new UIDefaults.LazyValue() {
     public Object createValue(UIDefaults table) {
         return new BorderFactory.createLoweredBevelBorder();
     }
 };

 uiDefaultsTable.put("MyBorder", borderLazyValue);
 
public 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. Here's an example of an ActiveValue that constructs a DefaultListCellRenderer:
 Object cellRendererActiveValue = new UIDefaults.ActiveValue() {
     public Object createValue(UIDefaults table) {
         return new DefaultListCellRenderer();
     }
 };

 uiDefaultsTable.put("MyRenderer", cellRendererActiveValue);
 
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. It also avoids creation of an anonymous inner class for the LazyValue subclass. Both of these improve performance at the time that a a Look and Feel is loaded, at the cost of a slight performance reduction the first time createValue is called (since Reflection APIs are used). 
public static class  UIDefaults.LazyInputMap  LazyInputMap will create a InputMap in its createValue method. The bindings are passed in in the constructor. The bindings are an array with the even number entries being string KeyStrokes (eg "alt SPACE") and the odd number entries being the value to use in the InputMap (and the key in the ActionMap). 
Constructor:
 public UIDefaults() 
 public UIDefaults(Object[] keyValueList) 
    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);
    
    Parameters:
    keyValueList - an array of objects containing the key/value pairs
 public UIDefaults(int initialCapacity,
    float loadFactor) 
Method from javax.swing.UIDefaults Summary:
addPropertyChangeListener,   addResourceBundle,   firePropertyChange,   get,   get,   getBoolean,   getBoolean,   getBorder,   getBorder,   getColor,   getColor,   getDefaultLocale,   getDimension,   getDimension,   getFont,   getFont,   getIcon,   getIcon,   getInsets,   getInsets,   getInt,   getInt,   getPropertyChangeListeners,   getString,   getString,   getUI,   getUIClass,   getUIClass,   getUIError,   put,   putDefaults,   removePropertyChangeListener,   removeResourceBundle,   setDefaultLocale
Methods from java.util.Hashtable:
clear,   clone,   contains,   containsKey,   containsValue,   elements,   entrySet,   equals,   get,   hashCode,   isEmpty,   keySet,   keys,   put,   putAll,   rehash,   remove,   size,   toString,   values
Methods from java.util.Dictionary:
elements,   get,   isEmpty,   keys,   put,   remove,   size
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.swing.UIDefaults Detail:
 public synchronized  void addPropertyChangeListener(PropertyChangeListener listener) 
    Adds a PropertyChangeListener to the listener list. The listener is registered for all properties.

    A PropertyChangeEvent will get fired whenever a default is changed.

 public synchronized  void addResourceBundle(String bundleName) 
    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.
 protected  void firePropertyChange(String propertyName,
    Object oldValue,
    Object newValue) 
    Support for reporting bound property changes. If oldValue and newValue are not equal and the PropertyChangeEventx listener list isn't empty, then fire a PropertyChange event to each listener.
 public Object get(Object 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.
 public Object get(Object key,
    Locale l) 
    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.
 public boolean getBoolean(Object key) 
    If the value of key is boolean, return the boolean value, otherwise return false.
 public boolean getBoolean(Object key,
    Locale l) 
    If the value of key for the given Locale is boolean, return the boolean value, otherwise return false.
 public Border getBorder(Object key) 
    If the value of key is a Border return it, otherwise return null.
 public Border getBorder(Object key,
    Locale l) 
    If the value of key for the given Locale is a Border return it, otherwise return null.
 public Color getColor(Object key) 
    If the value of key is a Color return it, otherwise return null.
 public Color getColor(Object key,
    Locale l) 
    If the value of key for the given Locale is a Color return it, otherwise return null.
 public Locale getDefaultLocale() 
    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.
 public Dimension getDimension(Object key) 
    If the value of key is a Dimension return it, otherwise return null.
 public Dimension getDimension(Object key,
    Locale l) 
    If the value of key for the given Locale is a Dimension return it, otherwise return null.
 public Font getFont(Object key) 
    If the value of key is a Font return it, otherwise return null.
 public Font getFont(Object key,
    Locale l) 
    If the value of key for the given Locale is a Font return it, otherwise return null.
 public Icon getIcon(Object key) 
    If the value of key is an Icon return it, otherwise return null.
 public Icon getIcon(Object key,
    Locale l) 
    If the value of key for the given Locale is an Icon return it, otherwise return null.
 public Insets getInsets(Object key) 
    If the value of key is an Insets return it, otherwise return null.
 public Insets getInsets(Object key,
    Locale l) 
    If the value of key for the given Locale is an Insets return it, otherwise return null.
 public int getInt(Object key) 
    If the value of key is an Integer return its integer value, otherwise return 0.
 public 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.
 public synchronized PropertyChangeListener[] getPropertyChangeListeners() 
    Returns an array of all the PropertyChangeListeners added to this UIDefaults with addPropertyChangeListener().
 public String getString(Object key) 
    If the value of key is a String return it, otherwise return null.
 public String getString(Object key,
    Locale l) 
    If the value of key for the given Locale is a String return it, otherwise return null.
 public ComponentUI getUI(JComponent target) 
    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:
    • Look up the name of the ComponentUI implementation class under the value returned by target.getUIClassID().
    • Use the implementation classes static createUI() method to construct a look and feel delegate.
 public Class<ComponentUI> getUIClass(String uiClassID) 
    Returns the L&F class that renders this component.
 public Class<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. 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.

 protected  void getUIError(String msg) 
    If getUI() fails for any reason, it calls this method before returning null. Subclasses may choose to do more or less here.
 public Object put(Object key,
    Object value) 
    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.
 public  void putDefaults(Object[] keyValueList) 
    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.
 public synchronized  void removePropertyChangeListener(PropertyChangeListener listener) 
    Removes a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.
 public synchronized  void removeResourceBundle(String bundleName) 
    Removes a resource bundle from the list of resource bundles that are searched for localized defaults.
 public  void setDefaultLocale(Locale l) 
    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.