Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Swing 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.swing
Class UIDefaults

    java.lang.Object
      |
      +--java.util.Dictionary
            |
            +--java.util.Hashtable
                  |
                  +--javax.swing.UIDefaults

public class UIDefaults
extends java.util.Hashtable

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. A future release of Swing will provide support for long term persistence.

See Also:
  `UIManager`, Serialized Form

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 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.

Constructor Summary
`UIDefaults()` Create an empty defaults table.
`UIDefaults(java.lang.Object[] keyValueList)` Create a defaults table initialized with the specified key/value pairs.

Method Summary
`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)` Returns the value for key.
`Border` | `getBorder(java.lang.Object key)` If the value of `key` is a Border return it, otherwise return null.
`java.awt.Color` | `getColor(java.lang.Object key)` If the value of `key` is a Color return it, otherwise return null.
`java.awt.Dimension` | `getDimension(java.lang.Object key)` If the value of `key` is a Dimension return it, otherwise return null.
`java.awt.Font` | `getFont(java.lang.Object key)` If the value of `key` is a Font return it, otherwise return null.
`Icon` | `getIcon(java.lang.Object key)` If the value of `key` is an Icon return it, otherwise return null.
`java.awt.Insets` | `getInsets(java.lang.Object key)` If the value of `key` is a Insets 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.
`java.lang.String` | `getString(java.lang.Object key)` If the value of `key` is a String return it, otherwise return null.
`ComponentUI` | `getUI(JComponent target)` Create an ComponentUI implementation for the specified component.
`java.lang.Class` | `getUIClass(java.lang.String uiClassID)` Returns the L&F class that renders this component.
`java.lang.Class` | `getUIClass(java.lang.String uiClassID, java.lang.ClassLoader uiClassLoader)` The value of get(uidClassID) must be the String name of a class that implements the corresponding ComponentUI class.
`protected void` | `getUIError(java.lang.String msg)` If getUI() fails for any reason, it calls this method before returning 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.

Methods inherited from class java.util.Hashtable
`clear, clone, contains, containsKey, elements, isEmpty, keys, rehash, remove, size, toString`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### UIDefaults

    public UIDefaults()

  Create an empty defaults table.

### UIDefaults

    public UIDefaults(java.lang.Object[] keyValueList)

  Create 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);

Method Detail

### get

    public java.lang.Object get(java.lang.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.
  Overrides:
    get in class java.util.Hashtable
  See Also:
    `UIDefaults.LazyValue`, `UIDefaults.ActiveValue`, `Hashtable.get(java.lang.Object)`

### put

    public java.lang.Object put(java.lang.Object key,
                                java.lang.Object value)

  Set the value of `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.
  Parameters:
    `key` - the unique Object who's value will be used to retreive the data value associated with it
    `value` - the new Object to store as data under that key
  Returns:
    the previous Object value, or null
  Overrides:
    put in class java.util.Hashtable
  See Also:
    `putDefaults(java.lang.Object[])`, `Hashtable.put(java.lang.Object, java.lang.Object)`

### putDefaults

    public void putDefaults(java.lang.Object[] keyValueList)

  Put all of the key/value pairs in the database and unconditionally generate one PropertyChangeEvent. The events oldValue and newValue will be null and its propertyName will be "UIDefaults".
  See Also:
    `put(java.lang.Object, java.lang.Object)`, `Hashtable.put(java.lang.Object, java.lang.Object)`

### getFont

    public java.awt.Font getFont(java.lang.Object key)

  If the value of `key` is a Font return it, otherwise return null.

### getColor

    public java.awt.Color getColor(java.lang.Object key)

  If the value of `key` is a Color return it, otherwise return null.

### getIcon

    public Icon getIcon(java.lang.Object key)

  If the value of `key` is an Icon return it, otherwise return null.

### getBorder

    public Border getBorder(java.lang.Object key)

  If the value of `key` is a Border return it, otherwise return null.

### getString

    public java.lang.String getString(java.lang.Object key)

  If the value of `key` is a String return it, otherwise return null.

### getInt

    public int getInt(java.lang.Object key)

  If the value of `key` is a Integer return its integer value, otherwise return 0.

### getInsets

    public java.awt.Insets getInsets(java.lang.Object key)

  If the value of `key` is a Insets return it, otherwise return null.

### getDimension

    public java.awt.Dimension getDimension(java.lang.Object key)

  If the value of `key` is a Dimension return it, otherwise return null.

### getUIClass

    public java.lang.Class getUIClass(java.lang.String uiClassID,
                                      java.lang.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 neccessary to call it directly.

  Returns:
    The value of `Class.forName(get(uidClassID))`.
  See Also:
    `getUI(javax.swing.JComponent)`

### getUIClass

    public java.lang.Class getUIClass(java.lang.String uiClassID)

  Returns the L&F class that renders this component.
  Returns:
    the Class object returned by getUIClass(uiClassID, null)

### getUIError

    protected void getUIError(java.lang.String msg)

  If getUI() fails for any reason, it calls this method before returning null. Subclasses may choose to do more or less here.
  Parameters:
    `msg` - Message string to print.
  See Also:
    `getUI(javax.swing.JComponent)`

### getUI

    public ComponentUI getUI(JComponent target)

  Create 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:
  - Lookup 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.

### addPropertyChangeListener

    public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)

  Add a PropertyChangeListener to the listener list. The listener is registered for all properties.

  A PropertyChangeEvent will get fired whenever a default is changed.

  Parameters:
    `listener` - The PropertyChangeListener to be added
  See Also:
    `PropertyChangeSupport`

### removePropertyChangeListener

    public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)

  Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.
  Parameters:
    `listener` - The PropertyChangeListener to be removed
  See Also:
    `PropertyChangeSupport`

### firePropertyChange

    protected void firePropertyChange(java.lang.String propertyName,
                                      java.lang.Object oldValue,
                                      java.lang.Object newValue)

  Support for reporting bound property changes. If oldValue and newValue are not equal and the PropertyChangeEvent listener list isn't empty, then fire a PropertyChange event to each listener.
  Parameters:
    `propertyName` - The programmatic name of the property that was changed.
    `oldValue` - The old value of the property.
    `newValue` - The new value of the property.
  See Also:
    `PropertyChangeSupport`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Swing 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Submit a bug or feature
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.