< prev index next >
src/java.desktop/share/classes/javax/swing/UIDefaults.java
Print this page
*** 54,72 ****
import sun.swing.SwingUtilities2;
import sun.util.CoreResourceBundleControl;
/**
* A table of defaults for Swing components. Applications can set/get
! * default values via the <code>UIManager</code>.
* <p>
* <strong>Warning:</strong>
* 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 JavaBeans™
! * has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @see UIManager
* @author Hans Muller
* @since 1.2
--- 54,72 ----
import sun.swing.SwingUtilities2;
import sun.util.CoreResourceBundleControl;
/**
* A table of defaults for Swing components. Applications can set/get
! * default values via the {@code UIManager}.
* <p>
* <strong>Warning:</strong>
* 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 JavaBeans™
! * has been added to the {@code java.beans} package.
* Please see {@link java.beans.XMLEncoder}.
*
* @see UIManager
* @author Hans Muller
* @since 1.2
*** 133,159 ****
}
}
/**
* Returns the value for key. If the value is a
! * <code>UIDefaults.LazyValue</code> then the real
! * value is computed with <code>LazyValue.createValue()</code>,
* the table entry is replaced, and the real value is returned.
! * If the value is an <code>UIDefaults.ActiveValue</code>
* the table entry is not replaced - the value is computed
! * with <code>ActiveValue.createValue()</code> for each
! * <code>get()</code> 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
! * <code>getDefaultLocale</code>. <code>LazyValues</code> and
! * <code>ActiveValues</code> are not supported in the resource bundles.
*
* @param key the desired key
! * @return the value for <code>key</code>
* @see LazyValue
* @see ActiveValue
* @see java.util.Hashtable#get
* @see #getDefaultLocale
* @see #addResourceBundle
--- 133,159 ----
}
}
/**
* Returns the value for key. If the value is a
! * {@code UIDefaults.LazyValue} then the real
! * value is computed with {@code LazyValue.createValue()},
* the table entry is replaced, and the real value is returned.
! * If the value is an {@code UIDefaults.ActiveValue}
* the table entry is not replaced - the value is computed
! * with {@code ActiveValue.createValue()} for each
! * {@code 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
! * {@code getDefaultLocale}. {@code LazyValues} and
! * {@code ActiveValues} are not supported in the resource bundles.
*
* @param key the desired key
! * @return the value for {@code key}
* @see LazyValue
* @see ActiveValue
* @see java.util.Hashtable#get
* @see #getDefaultLocale
* @see #addResourceBundle
*** 237,263 ****
}
/**
* Returns the value for key associated with the given locale.
! * If the value is a <code>UIDefaults.LazyValue</code> then the real
! * value is computed with <code>LazyValue.createValue()</code>,
* the table entry is replaced, and the real value is returned.
! * If the value is an <code>UIDefaults.ActiveValue</code>
* the table entry is not replaced - the value is computed
! * with <code>ActiveValue.createValue()</code> for each
! * <code>get()</code> 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.
! * <code>LazyValues</code> and <code>ActiveValues</code> are not supported
* in the resource bundles.
*
* @param key the desired key
! * @param l the desired <code>locale</code>
! * @return the value for <code>key</code>
* @see LazyValue
* @see ActiveValue
* @see java.util.Hashtable#get
* @see #addResourceBundle
* @since 1.4
--- 237,263 ----
}
/**
* Returns the value for key associated with the given locale.
! * If the value is a {@code UIDefaults.LazyValue} then the real
! * value is computed with {@code LazyValue.createValue()},
* the table entry is replaced, and the real value is returned.
! * If the value is an {@code UIDefaults.ActiveValue}
* the table entry is not replaced - the value is computed
! * with {@code ActiveValue.createValue()} for each
! * {@code 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.
! * {@code LazyValues} and {@code ActiveValues} are not supported
* in the resource bundles.
*
* @param key the desired key
! * @param l the desired {@code locale}
! * @return the value for {@code key}
* @see LazyValue
* @see ActiveValue
* @see java.util.Hashtable#get
* @see #addResourceBundle
* @since 1.4
*** 328,347 ****
}
return values;
}
/**
! * Sets the value of <code>key</code> to <code>value</code> for all locales.
! * If <code>key</code> is a string and the new value isn't
! * equal to the old one, fire a <code>PropertyChangeEvent</code>.
! * If value is <code>null</code>, the key is removed from the table.
*
! * @param key the unique <code>Object</code> who's value will be used
* to retrieve the data value associated with it
! * @param value the new <code>Object</code> to store as data under
* that key
! * @return the previous <code>Object</code> value, or <code>null</code>
* @see #putDefaults
* @see java.util.Hashtable#put
*/
public Object put(Object key, Object value) {
Object oldValue = (value == null) ? super.remove(key) : super.put(key, value);
--- 328,347 ----
}
return values;
}
/**
! * Sets the value of {@code key} to {@code value} for all locales.
! * If {@code key} is a string and the new value isn't
! * equal to the old one, fire a {@code PropertyChangeEvent}.
! * If value is {@code null}, the key is removed from the table.
*
! * @param key the unique {@code Object} who's value will be used
* to retrieve the data value associated with it
! * @param value the new {@code Object} to store as data under
* that key
! * @return the previous {@code Object} value, or {@code null}
* @see #putDefaults
* @see java.util.Hashtable#put
*/
public Object put(Object key, Object value) {
Object oldValue = (value == null) ? super.remove(key) : super.put(key, value);
*** 352,364 ****
}
/**
* Puts all of the key/value pairs in the database and
! * unconditionally generates one <code>PropertyChangeEvent</code>.
! * The events oldValue and newValue will be <code>null</code> and its
! * <code>propertyName</code> will be "UIDefaults". The key/value pairs are
* added for all locales.
*
* @param keyValueList an array of key/value pairs
* @see #put
* @see java.util.Hashtable#put
--- 352,364 ----
}
/**
* Puts all of the key/value pairs in the database and
! * unconditionally generates one {@code PropertyChangeEvent}.
! * The events oldValue and newValue will be {@code null} and its
! * {@code propertyName} will be "UIDefaults". The key/value pairs are
* added for all locales.
*
* @param keyValueList an array of key/value pairs
* @see #put
* @see java.util.Hashtable#put
*** 376,587 ****
firePropertyChange("UIDefaults", null, null);
}
/**
! * If the value of <code>key</code> is a <code>Font</code> return it,
! * otherwise return <code>null</code>.
* @param key the desired key
! * @return if the value for <code>key</code> is a <code>Font</code>,
! * return the <code>Font</code> object; otherwise return
! * <code>null</code>
*/
public Font getFont(Object key) {
Object value = get(key);
return (value instanceof Font) ? (Font)value : null;
}
/**
! * If the value of <code>key</code> for the given <code>Locale</code>
! * is a <code>Font</code> return it, otherwise return <code>null</code>.
* @param key the desired key
* @param l the desired locale
! * @return if the value for <code>key</code> and <code>Locale</code>
! * is a <code>Font</code>,
! * return the <code>Font</code> object; otherwise return
! * <code>null</code>
* @since 1.4
*/
public Font getFont(Object key, Locale l) {
Object value = get(key,l);
return (value instanceof Font) ? (Font)value : null;
}
/**
! * If the value of <code>key</code> is a <code>Color</code> return it,
! * otherwise return <code>null</code>.
* @param key the desired key
! * @return if the value for <code>key</code> is a <code>Color</code>,
! * return the <code>Color</code> object; otherwise return
! * <code>null</code>
*/
public Color getColor(Object key) {
Object value = get(key);
return (value instanceof Color) ? (Color)value : null;
}
/**
! * If the value of <code>key</code> for the given <code>Locale</code>
! * is a <code>Color</code> return it, otherwise return <code>null</code>.
* @param key the desired key
* @param l the desired locale
! * @return if the value for <code>key</code> and <code>Locale</code>
! * is a <code>Color</code>,
! * return the <code>Color</code> object; otherwise return
! * <code>null</code>
* @since 1.4
*/
public Color getColor(Object key, Locale l) {
Object value = get(key,l);
return (value instanceof Color) ? (Color)value : null;
}
/**
! * If the value of <code>key</code> is an <code>Icon</code> return it,
! * otherwise return <code>null</code>.
* @param key the desired key
! * @return if the value for <code>key</code> is an <code>Icon</code>,
! * return the <code>Icon</code> object; otherwise return
! * <code>null</code>
*/
public Icon getIcon(Object key) {
Object value = get(key);
return (value instanceof Icon) ? (Icon)value : null;
}
/**
! * If the value of <code>key</code> for the given <code>Locale</code>
! * is an <code>Icon</code> return it, otherwise return <code>null</code>.
* @param key the desired key
* @param l the desired locale
! * @return if the value for <code>key</code> and <code>Locale</code>
! * is an <code>Icon</code>,
! * return the <code>Icon</code> object; otherwise return
! * <code>null</code>
* @since 1.4
*/
public Icon getIcon(Object key, Locale l) {
Object value = get(key,l);
return (value instanceof Icon) ? (Icon)value : null;
}
/**
! * If the value of <code>key</code> is a <code>Border</code> return it,
! * otherwise return <code>null</code>.
* @param key the desired key
! * @return if the value for <code>key</code> is a <code>Border</code>,
! * return the <code>Border</code> object; otherwise return
! * <code>null</code>
*/
public Border getBorder(Object key) {
Object value = get(key);
return (value instanceof Border) ? (Border)value : null;
}
/**
! * If the value of <code>key</code> for the given <code>Locale</code>
! * is a <code>Border</code> return it, otherwise return <code>null</code>.
* @param key the desired key
* @param l the desired locale
! * @return if the value for <code>key</code> and <code>Locale</code>
! * is a <code>Border</code>,
! * return the <code>Border</code> object; otherwise return
! * <code>null</code>
* @since 1.4
*/
public Border getBorder(Object key, Locale l) {
Object value = get(key,l);
return (value instanceof Border) ? (Border)value : null;
}
/**
! * If the value of <code>key</code> is a <code>String</code> return it,
! * otherwise return <code>null</code>.
* @param key the desired key
! * @return if the value for <code>key</code> is a <code>String</code>,
! * return the <code>String</code> object; otherwise return
! * <code>null</code>
*/
public String getString(Object key) {
Object value = get(key);
return (value instanceof String) ? (String)value : null;
}
/**
! * If the value of <code>key</code> for the given <code>Locale</code>
! * is a <code>String</code> return it, otherwise return <code>null</code>.
* @param key the desired key
! * @param l the desired <code>Locale</code>
! * @return if the value for <code>key</code> for the given
! * <code>Locale</code> is a <code>String</code>,
! * return the <code>String</code> object; otherwise return
! * <code>null</code>
* @since 1.4
*/
public String getString(Object key, Locale l) {
Object value = get(key,l);
return (value instanceof String) ? (String)value : null;
}
/**
! * If the value of <code>key</code> is an <code>Integer</code> return its
* integer value, otherwise return 0.
* @param key the desired key
! * @return if the value for <code>key</code> is an <code>Integer</code>,
* return its value, otherwise return 0
*/
public int getInt(Object key) {
Object value = get(key);
return (value instanceof Integer) ? ((Integer)value).intValue() : 0;
}
/**
! * If the value of <code>key</code> for the given <code>Locale</code>
! * is an <code>Integer</code> return its integer value, otherwise return 0.
* @param key the desired key
* @param l the desired locale
! * @return if the value for <code>key</code> and <code>Locale</code>
! * is an <code>Integer</code>,
* return its value, otherwise return 0
* @since 1.4
*/
public int getInt(Object key, Locale l) {
Object value = get(key,l);
return (value instanceof Integer) ? ((Integer)value).intValue() : 0;
}
/**
! * If the value of <code>key</code> is boolean, return the
* boolean value, otherwise return false.
*
! * @param key an <code>Object</code> specifying the key for the desired boolean value
! * @return if the value of <code>key</code> is boolean, return the
* boolean value, otherwise return false.
* @since 1.4
*/
public boolean getBoolean(Object key) {
Object value = get(key);
return (value instanceof Boolean) ? ((Boolean)value).booleanValue() : false;
}
/**
! * If the value of <code>key</code> for the given <code>Locale</code>
* is boolean, return the boolean value, otherwise return false.
*
! * @param key an <code>Object</code> specifying the key for the desired boolean value
* @param l the desired locale
! * @return if the value for <code>key</code> and <code>Locale</code>
* is boolean, return the
* boolean value, otherwise return false.
* @since 1.4
*/
public boolean getBoolean(Object key, Locale l) {
--- 376,587 ----
firePropertyChange("UIDefaults", null, null);
}
/**
! * If the value of {@code key} is a {@code Font} return it,
! * otherwise return {@code null}.
* @param key the desired key
! * @return if the value for {@code key} is a {@code Font},
! * return the {@code Font} object; otherwise return
! * {@code null}
*/
public Font getFont(Object key) {
Object value = get(key);
return (value instanceof Font) ? (Font)value : null;
}
/**
! * If the value of {@code key} for the given {@code Locale}
! * is a {@code Font} return it, otherwise return {@code null}.
* @param key the desired key
* @param l the desired locale
! * @return if the value for {@code key} and {@code Locale}
! * is a {@code Font},
! * return the {@code Font} object; otherwise return
! * {@code null}
* @since 1.4
*/
public Font getFont(Object key, Locale l) {
Object value = get(key,l);
return (value instanceof Font) ? (Font)value : null;
}
/**
! * If the value of {@code key} is a {@code Color} return it,
! * otherwise return {@code null}.
* @param key the desired key
! * @return if the value for {@code key} is a {@code Color},
! * return the {@code Color} object; otherwise return
! * {@code null}
*/
public Color getColor(Object key) {
Object value = get(key);
return (value instanceof Color) ? (Color)value : null;
}
/**
! * If the value of {@code key} for the given {@code Locale}
! * is a {@code Color} return it, otherwise return {@code null}.
* @param key the desired key
* @param l the desired locale
! * @return if the value for {@code key} and {@code Locale}
! * is a {@code Color},
! * return the {@code Color} object; otherwise return
! * {@code null}
* @since 1.4
*/
public Color getColor(Object key, Locale l) {
Object value = get(key,l);
return (value instanceof Color) ? (Color)value : null;
}
/**
! * If the value of {@code key} is an {@code Icon} return it,
! * otherwise return {@code null}.
* @param key the desired key
! * @return if the value for {@code key} is an {@code Icon},
! * return the {@code Icon} object; otherwise return
! * {@code null}
*/
public Icon getIcon(Object key) {
Object value = get(key);
return (value instanceof Icon) ? (Icon)value : null;
}
/**
! * If the value of {@code key} for the given {@code Locale}
! * is an {@code Icon} return it, otherwise return {@code null}.
* @param key the desired key
* @param l the desired locale
! * @return if the value for {@code key} and {@code Locale}
! * is an {@code Icon},
! * return the {@code Icon} object; otherwise return
! * {@code null}
* @since 1.4
*/
public Icon getIcon(Object key, Locale l) {
Object value = get(key,l);
return (value instanceof Icon) ? (Icon)value : null;
}
/**
! * If the value of {@code key} is a {@code Border} return it,
! * otherwise return {@code null}.
* @param key the desired key
! * @return if the value for {@code key} is a {@code Border},
! * return the {@code Border} object; otherwise return
! * {@code null}
*/
public Border getBorder(Object key) {
Object value = get(key);
return (value instanceof Border) ? (Border)value : null;
}
/**
! * If the value of {@code key} for the given {@code Locale}
! * is a {@code Border} return it, otherwise return {@code null}.
* @param key the desired key
* @param l the desired locale
! * @return if the value for {@code key} and {@code Locale}
! * is a {@code Border},
! * return the {@code Border} object; otherwise return
! * {@code null}
* @since 1.4
*/
public Border getBorder(Object key, Locale l) {
Object value = get(key,l);
return (value instanceof Border) ? (Border)value : null;
}
/**
! * If the value of {@code key} is a {@code String} return it,
! * otherwise return {@code null}.
* @param key the desired key
! * @return if the value for {@code key} is a {@code String},
! * return the {@code String} object; otherwise return
! * {@code null}
*/
public String getString(Object key) {
Object value = get(key);
return (value instanceof String) ? (String)value : null;
}
/**
! * If the value of {@code key} for the given {@code Locale}
! * is a {@code String} return it, otherwise return {@code null}.
* @param key the desired key
! * @param l the desired {@code Locale}
! * @return if the value for {@code key} for the given
! * {@code Locale} is a {@code String},
! * return the {@code String} object; otherwise return
! * {@code null}
* @since 1.4
*/
public String getString(Object key, Locale l) {
Object value = get(key,l);
return (value instanceof String) ? (String)value : null;
}
/**
! * If the value of {@code key} is an {@code Integer} return its
* integer value, otherwise return 0.
* @param key the desired key
! * @return if the value for {@code key} is an {@code Integer},
* return its value, otherwise return 0
*/
public int getInt(Object key) {
Object value = get(key);
return (value instanceof Integer) ? ((Integer)value).intValue() : 0;
}
/**
! * If the value of {@code key} for the given {@code Locale}
! * is an {@code Integer} return its integer value, otherwise return 0.
* @param key the desired key
* @param l the desired locale
! * @return if the value for {@code key} and {@code Locale}
! * is an {@code Integer},
* return its value, otherwise return 0
* @since 1.4
*/
public int getInt(Object key, Locale l) {
Object value = get(key,l);
return (value instanceof Integer) ? ((Integer)value).intValue() : 0;
}
/**
! * If the value of {@code key} is boolean, return the
* boolean value, otherwise return false.
*
! * @param key an {@code Object} specifying the key for the desired boolean value
! * @return if the value of {@code key} is boolean, return the
* boolean value, otherwise return false.
* @since 1.4
*/
public boolean getBoolean(Object key) {
Object value = get(key);
return (value instanceof Boolean) ? ((Boolean)value).booleanValue() : false;
}
/**
! * If the value of {@code key} for the given {@code Locale}
* is boolean, return the boolean value, otherwise return false.
*
! * @param key an {@code Object} specifying the key for the desired boolean value
* @param l the desired locale
! * @return if the value for {@code key} and {@code Locale}
* is boolean, return the
* boolean value, otherwise return false.
* @since 1.4
*/
public boolean getBoolean(Object key, Locale l) {
*** 589,677 ****
return (value instanceof Boolean) ? ((Boolean)value).booleanValue() : false;
}
/**
! * If the value of <code>key</code> is an <code>Insets</code> return it,
! * otherwise return <code>null</code>.
* @param key the desired key
! * @return if the value for <code>key</code> is an <code>Insets</code>,
! * return the <code>Insets</code> object; otherwise return
! * <code>null</code>
*/
public Insets getInsets(Object key) {
Object value = get(key);
return (value instanceof Insets) ? (Insets)value : null;
}
/**
! * If the value of <code>key</code> for the given <code>Locale</code>
! * is an <code>Insets</code> return it, otherwise return <code>null</code>.
* @param key the desired key
* @param l the desired locale
! * @return if the value for <code>key</code> and <code>Locale</code>
! * is an <code>Insets</code>,
! * return the <code>Insets</code> object; otherwise return
! * <code>null</code>
* @since 1.4
*/
public Insets getInsets(Object key, Locale l) {
Object value = get(key,l);
return (value instanceof Insets) ? (Insets)value : null;
}
/**
! * If the value of <code>key</code> is a <code>Dimension</code> return it,
! * otherwise return <code>null</code>.
* @param key the desired key
! * @return if the value for <code>key</code> is a <code>Dimension</code>,
! * return the <code>Dimension</code> object; otherwise return
! * <code>null</code>
*/
public Dimension getDimension(Object key) {
Object value = get(key);
return (value instanceof Dimension) ? (Dimension)value : null;
}
/**
! * If the value of <code>key</code> for the given <code>Locale</code>
! * is a <code>Dimension</code> return it, otherwise return <code>null</code>.
* @param key the desired key
* @param l the desired locale
! * @return if the value for <code>key</code> and <code>Locale</code>
! * is a <code>Dimension</code>,
! * return the <code>Dimension</code> object; otherwise return
! * <code>null</code>
* @since 1.4
*/
public Dimension getDimension(Object key, Locale l) {
Object value = get(key,l);
return (value instanceof Dimension) ? (Dimension)value : null;
}
/**
! * The value of <code>get(uidClassID)</code> must be the
! * <code>String</code> name of a
! * class that implements the corresponding <code>ComponentUI</code>
* class. If the class hasn't been loaded before, this method looks
! * up the class with <code>uiClassLoader.loadClass()</code> if a non
! * <code>null</code>
! * class loader is provided, <code>classForName()</code> otherwise.
* <p>
! * If a mapping for <code>uiClassID</code> exists or if the specified
! * class can't be found, return <code>null</code>.
* <p>
! * This method is used by <code>getUI</code>, it's usually
* not necessary to call it directly.
*
* @param uiClassID a string containing the class ID
* @param uiClassLoader the object which will load the class
! * @return the value of <code>Class.forName(get(uidClassID))</code>
* @see #getUI
*/
public Class<? extends ComponentUI>
getUIClass(String uiClassID, ClassLoader uiClassLoader)
{
--- 589,677 ----
return (value instanceof Boolean) ? ((Boolean)value).booleanValue() : false;
}
/**
! * If the value of {@code key} is an {@code Insets} return it,
! * otherwise return {@code null}.
* @param key the desired key
! * @return if the value for {@code key} is an {@code Insets},
! * return the {@code Insets} object; otherwise return
! * {@code null}
*/
public Insets getInsets(Object key) {
Object value = get(key);
return (value instanceof Insets) ? (Insets)value : null;
}
/**
! * If the value of {@code key} for the given {@code Locale}
! * is an {@code Insets} return it, otherwise return {@code null}.
* @param key the desired key
* @param l the desired locale
! * @return if the value for {@code key} and {@code Locale}
! * is an {@code Insets},
! * return the {@code Insets} object; otherwise return
! * {@code null}
* @since 1.4
*/
public Insets getInsets(Object key, Locale l) {
Object value = get(key,l);
return (value instanceof Insets) ? (Insets)value : null;
}
/**
! * If the value of {@code key} is a {@code Dimension} return it,
! * otherwise return {@code null}.
* @param key the desired key
! * @return if the value for {@code key} is a {@code Dimension},
! * return the {@code Dimension} object; otherwise return
! * {@code null}
*/
public Dimension getDimension(Object key) {
Object value = get(key);
return (value instanceof Dimension) ? (Dimension)value : null;
}
/**
! * If the value of {@code key} for the given {@code Locale}
! * is a {@code Dimension} return it, otherwise return {@code null}.
* @param key the desired key
* @param l the desired locale
! * @return if the value for {@code key} and {@code Locale}
! * is a {@code Dimension},
! * return the {@code Dimension} object; otherwise return
! * {@code null}
* @since 1.4
*/
public Dimension getDimension(Object key, Locale l) {
Object value = get(key,l);
return (value instanceof Dimension) ? (Dimension)value : null;
}
/**
! * The value of {@code get(uidClassID)} must be the
! * {@code String} name of a
! * class that implements the corresponding {@code ComponentUI}
* class. If the class hasn't been loaded before, this method looks
! * up the class with {@code uiClassLoader.loadClass()} if a non
! * {@code null}
! * class loader is provided, {@code classForName()} otherwise.
* <p>
! * If a mapping for {@code uiClassID} exists or if the specified
! * class can't be found, return {@code null}.
* <p>
! * This method is used by {@code getUI}, it's usually
* not necessary to call it directly.
*
* @param uiClassID a string containing the class ID
* @param uiClassLoader the object which will load the class
! * @return the value of {@code Class.forName(get(uidClassID))}
* @see #getUI
*/
public Class<? extends ComponentUI>
getUIClass(String uiClassID, ClassLoader uiClassLoader)
{
*** 708,727 ****
/**
* Returns the L&F class that renders this component.
*
* @param uiClassID a string containing the class ID
* @return the Class object returned by
! * <code>getUIClass(uiClassID, null)</code>
*/
public Class<? extends ComponentUI> getUIClass(String uiClassID) {
return getUIClass(uiClassID, null);
}
/**
! * If <code>getUI()</code> fails for any reason,
! * it calls this method before returning <code>null</code>.
* Subclasses may choose to do more or less here.
*
* @param msg message string to print
* @see #getUI
*/
--- 708,727 ----
/**
* Returns the L&F class that renders this component.
*
* @param uiClassID a string containing the class ID
* @return the Class object returned by
! * {@code getUIClass(uiClassID, null)}
*/
public Class<? extends ComponentUI> getUIClass(String uiClassID) {
return getUIClass(uiClassID, null);
}
/**
! * If {@code getUI()} fails for any reason,
! * it calls this method before returning {@code null}.
* Subclasses may choose to do more or less here.
*
* @param msg message string to print
* @see #getUI
*/
*** 734,755 ****
e.printStackTrace();
}
}
/**
! * Creates an <code>ComponentUI</code> implementation for the
* specified component. In other words create the look
! * and feel specific delegate object for <code>target</code>.
* This is done in two steps:
* <ul>
! * <li> Look up the name of the <code>ComponentUI</code> implementation
! * class under the value returned by <code>target.getUIClassID()</code>.
! * <li> Use the implementation classes static <code>createUI()</code>
* method to construct a look and feel delegate.
* </ul>
! * @param target the <code>JComponent</code> which needs a UI
! * @return the <code>ComponentUI</code> object
*/
public ComponentUI getUI(JComponent target) {
Object cl = get("ClassLoader");
ClassLoader uiClassLoader =
--- 734,755 ----
e.printStackTrace();
}
}
/**
! * Creates an {@code ComponentUI} implementation for the
* specified component. In other words create the look
! * and feel specific delegate object for {@code target}.
* This is done in two steps:
* <ul>
! * <li> Look up the name of the {@code ComponentUI} implementation
! * class under the value returned by {@code target.getUIClassID()}.
! * <li> Use the implementation classes static {@code createUI()}
* method to construct a look and feel delegate.
* </ul>
! * @param target the {@code JComponent} which needs a UI
! * @return the {@code ComponentUI} object
*/
public ComponentUI getUI(JComponent target) {
Object cl = get("ClassLoader");
ClassLoader uiClassLoader =
*** 779,795 ****
return (ComponentUI)uiObject;
}
/**
! * Adds a <code>PropertyChangeListener</code> to the listener list.
* The listener is registered for all properties.
* <p>
! * A <code>PropertyChangeEvent</code> will get fired whenever a default
* is changed.
*
! * @param listener the <code>PropertyChangeListener</code> to be added
* @see java.beans.PropertyChangeSupport
*/
public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
if (changeSupport == null) {
changeSupport = new SwingPropertyChangeSupport(this);
--- 779,795 ----
return (ComponentUI)uiObject;
}
/**
! * Adds a {@code PropertyChangeListener} to the listener list.
* The listener is registered for all properties.
* <p>
! * A {@code PropertyChangeEvent} will get fired whenever a default
* is changed.
*
! * @param listener the {@code PropertyChangeListener} to be added
* @see java.beans.PropertyChangeSupport
*/
public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
if (changeSupport == null) {
changeSupport = new SwingPropertyChangeSupport(this);
*** 797,825 ****
changeSupport.addPropertyChangeListener(listener);
}
/**
! * Removes a <code>PropertyChangeListener</code> from the listener list.
! * This removes a <code>PropertyChangeListener</code> that was registered
* for all properties.
*
! * @param listener the <code>PropertyChangeListener</code> to be removed
* @see java.beans.PropertyChangeSupport
*/
public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
if (changeSupport != null) {
changeSupport.removePropertyChangeListener(listener);
}
}
/**
! * Returns an array of all the <code>PropertyChangeListener</code>s added
* to this UIDefaults with addPropertyChangeListener().
*
! * @return all of the <code>PropertyChangeListener</code>s added or an empty
* array if no listeners have been added
* @since 1.4
*/
public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
if (changeSupport == null) {
--- 797,825 ----
changeSupport.addPropertyChangeListener(listener);
}
/**
! * Removes a {@code PropertyChangeListener} from the listener list.
! * This removes a {@code PropertyChangeListener} that was registered
* for all properties.
*
! * @param listener the {@code PropertyChangeListener} to be removed
* @see java.beans.PropertyChangeSupport
*/
public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
if (changeSupport != null) {
changeSupport.removePropertyChangeListener(listener);
}
}
/**
! * Returns an array of all the {@code PropertyChangeListener}s added
* to this UIDefaults with addPropertyChangeListener().
*
! * @return all of the {@code PropertyChangeListener}s added or an empty
* array if no listeners have been added
* @since 1.4
*/
public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
if (changeSupport == null) {
*** 829,841 ****
}
/**
* Support for reporting bound property changes. If oldValue and
! * newValue are not equal and the <code>PropertyChangeEvent</code>x
* listener list isn't empty, then fire a
! * <code>PropertyChange</code> event to each listener.
*
* @param propertyName the programmatic name of the property
* that was changed
* @param oldValue the old value of the property
* @param newValue the new value of the property
--- 829,841 ----
}
/**
* Support for reporting bound property changes. If oldValue and
! * newValue are not equal and the {@code PropertyChangeEvent}x
* listener list isn't empty, then fire a
! * {@code PropertyChange} event to each listener.
*
* @param propertyName the programmatic name of the property
* that was changed
* @param oldValue the old value of the property
* @param newValue the new value of the property
*** 889,899 ****
resourceCache.clear();
}
/**
* Sets the default locale. The default locale is used in retrieving
! * localized values via <code>get</code> 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.
*
--- 889,899 ----
resourceCache.clear();
}
/**
* Sets the default locale. The default locale is used in retrieving
! * localized values via {@code 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.
*
*** 907,917 ****
defaultLocale = l;
}
/**
* Returns the default locale. The default locale is used in retrieving
! * localized values via <code>get</code> 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.
*
--- 907,917 ----
defaultLocale = l;
}
/**
* Returns the default locale. The default locale is used in retrieving
! * localized values via {@code 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.
*
*** 926,945 ****
}
/**
* 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 <code>getXXX(key)</code> methods.
* Lazy values are useful for defaults that are expensive
* to construct or are seldom retrieved. The first time
! * a <code>LazyValue</code> is retrieved its "real value" is computed
! * by calling <code>LazyValue.createValue()</code> and the real
! * value is used to replace the <code>LazyValue</code> in the
! * <code>UIDefaults</code>
* table. Subsequent lookups for the same key return
! * the real value. Here's an example of a <code>LazyValue</code>
! * that constructs a <code>Border</code>:
* <pre>
* Object borderLazyValue = new UIDefaults.LazyValue() {
* public Object createValue(UIDefaults table) {
* return new BorderFactory.createLoweredBevelBorder();
* }
--- 926,945 ----
}
/**
* 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 {@code getXXX(key)} methods.
* Lazy values are useful for defaults that are expensive
* to construct or are seldom retrieved. The first time
! * a {@code LazyValue} is retrieved its "real value" is computed
! * by calling {@code LazyValue.createValue()} and the real
! * value is used to replace the {@code LazyValue} in the
! * {@code UIDefaults}
* table. Subsequent lookups for the same key return
! * the real value. Here's an example of a {@code LazyValue}
! * that constructs a {@code Border}:
* <pre>
* Object borderLazyValue = new UIDefaults.LazyValue() {
* public Object createValue(UIDefaults table) {
* return new BorderFactory.createLoweredBevelBorder();
* }
*** 950,978 ****
*
* @see UIDefaults#get
*/
public interface LazyValue {
/**
! * Creates the actual value retrieved from the <code>UIDefaults</code>
* table. When an object that implements this interface is
* retrieved from the table, this method is used to create
* the real value, which is then stored in the table and
* returned to the calling method.
*
! * @param table a <code>UIDefaults</code> table
! * @return the created <code>Object</code>
*/
Object createValue(UIDefaults table);
}
/**
* 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 <code>getXXX(key)</code> methods. Here's an example of
! * an <code>ActiveValue</code> that constructs a
! * <code>DefaultListCellRenderer</code>:
* <pre>
* Object cellRendererActiveValue = new UIDefaults.ActiveValue() {
* public Object createValue(UIDefaults table) {
* return new DefaultListCellRenderer();
* }
--- 950,978 ----
*
* @see UIDefaults#get
*/
public interface LazyValue {
/**
! * Creates the actual value retrieved from the {@code UIDefaults}
* table. When an object that implements this interface is
* retrieved from the table, this method is used to create
* the real value, which is then stored in the table and
* returned to the calling method.
*
! * @param table a {@code UIDefaults} table
! * @return the created {@code Object}
*/
Object createValue(UIDefaults table);
}
/**
* 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 {@code getXXX(key)} methods. Here's an example of
! * an {@code ActiveValue} that constructs a
! * {@code DefaultListCellRenderer}:
* <pre>
* Object cellRendererActiveValue = new UIDefaults.ActiveValue() {
* public Object createValue(UIDefaults table) {
* return new DefaultListCellRenderer();
* }
*** 983,1066 ****
*
* @see UIDefaults#get
*/
public interface ActiveValue {
/**
! * Creates the value retrieved from the <code>UIDefaults</code> table.
* The object is created each time it is accessed.
*
! * @param table a <code>UIDefaults</code> table
! * @return the created <code>Object</code>
*/
Object createValue(UIDefaults table);
}
/**
! * This class provides an implementation of <code>LazyValue</code>
* 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
! * <code>LazyValue</code>
* 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 <code>createValue</code> is called
* (since Reflection APIs are used).
* @since 1.3
*/
public static class ProxyLazyValue implements LazyValue {
private AccessControlContext acc;
private String className;
private String methodName;
private Object[] args;
/**
! * Creates a <code>LazyValue</code> which will construct an instance
* when asked.
*
! * @param c a <code>String</code> specifying the classname
* of the instance to be created on demand
*/
public ProxyLazyValue(String c) {
this(c, (String)null);
}
/**
! * Creates a <code>LazyValue</code> which will construct an instance
* when asked.
*
! * @param c a <code>String</code> specifying the classname of
* the class
* containing a static method to be called for
* instance creation
! * @param m a <code>String</code> specifying the static
* method to be called on class c
*/
public ProxyLazyValue(String c, String m) {
this(c, m, null);
}
/**
! * Creates a <code>LazyValue</code> which will construct an instance
* when asked.
*
! * @param c a <code>String</code> specifying the classname
* of the instance to be created on demand
! * @param o an array of <code>Objects</code> to be passed as
* paramaters to the constructor in class c
*/
public ProxyLazyValue(String c, Object[] o) {
this(c, null, o);
}
/**
! * Creates a <code>LazyValue</code> which will construct an instance
* when asked.
*
! * @param c a <code>String</code> specifying the classname
* of the class
* containing a static method to be called for
* instance creation.
! * @param m a <code>String</code> specifying the static method
* to be called on class c
! * @param o an array of <code>Objects</code> to be passed as
* paramaters to the static method in class c
*/
public ProxyLazyValue(String c, String m, Object[] o) {
acc = AccessController.getContext();
className = c;
--- 983,1066 ----
*
* @see UIDefaults#get
*/
public interface ActiveValue {
/**
! * Creates the value retrieved from the {@code UIDefaults} table.
* The object is created each time it is accessed.
*
! * @param table a {@code UIDefaults} table
! * @return the created {@code Object}
*/
Object createValue(UIDefaults table);
}
/**
! * This class provides an implementation of {@code 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
! * {@code 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 {@code createValue} is called
* (since Reflection APIs are used).
* @since 1.3
*/
public static class ProxyLazyValue implements LazyValue {
private AccessControlContext acc;
private String className;
private String methodName;
private Object[] args;
/**
! * Creates a {@code LazyValue} which will construct an instance
* when asked.
*
! * @param c a {@code String} specifying the classname
* of the instance to be created on demand
*/
public ProxyLazyValue(String c) {
this(c, (String)null);
}
/**
! * Creates a {@code LazyValue} which will construct an instance
* when asked.
*
! * @param c a {@code String} specifying the classname of
* the class
* containing a static method to be called for
* instance creation
! * @param m a {@code String} specifying the static
* method to be called on class c
*/
public ProxyLazyValue(String c, String m) {
this(c, m, null);
}
/**
! * Creates a {@code LazyValue} which will construct an instance
* when asked.
*
! * @param c a {@code String} specifying the classname
* of the instance to be created on demand
! * @param o an array of {@code Objects} to be passed as
* paramaters to the constructor in class c
*/
public ProxyLazyValue(String c, Object[] o) {
this(c, null, o);
}
/**
! * Creates a {@code LazyValue} which will construct an instance
* when asked.
*
! * @param c a {@code String} specifying the classname
* of the class
* containing a static method to be called for
* instance creation.
! * @param m a {@code String} specifying the static method
* to be called on class c
! * @param o an array of {@code Objects} to be passed as
* paramaters to the static method in class c
*/
public ProxyLazyValue(String c, String m, Object[] o) {
acc = AccessController.getContext();
className = c;
*** 1069,1083 ****
args = o.clone();
}
}
/**
! * Creates the value retrieved from the <code>UIDefaults</code> table.
* The object is created each time it is accessed.
*
! * @param table a <code>UIDefaults</code> table
! * @return the created <code>Object</code>
*/
public Object createValue(final UIDefaults table) {
// In order to pick up the security policy in effect at the
// time of creation we use a doPrivileged with the
// AccessControlContext that was in place when this was created.
--- 1069,1083 ----
args = o.clone();
}
}
/**
! * Creates the value retrieved from the {@code UIDefaults} table.
* The object is created each time it is accessed.
*
! * @param table a {@code UIDefaults} table
! * @return the created {@code Object}
*/
public Object createValue(final UIDefaults table) {
// In order to pick up the security policy in effect at the
// time of creation we use a doPrivileged with the
// AccessControlContext that was in place when this was created.
*** 1127,1137 ****
/*
* Coerce the array of class types provided into one which
* looks the way the Reflection APIs expect. This is done
* by substituting primitive types for their Object counterparts,
* and superclasses for subclasses used to add the
! * <code>UIResource</code> tag.
*/
private Class<?>[] getClassArray(Object[] args) {
Class<?>[] types = null;
if (args!=null) {
types = new Class<?>[args.length];
--- 1127,1137 ----
/*
* Coerce the array of class types provided into one which
* looks the way the Reflection APIs expect. This is done
* by substituting primitive types for their Object counterparts,
* and superclasses for subclasses used to add the
! * {@code UIResource} tag.
*/
private Class<?>[] getClassArray(Object[] args) {
Class<?>[] types = null;
if (args!=null) {
types = new Class<?>[args.length];
*** 1175,1192 ****
}
}
/**
! * <code>LazyInputMap</code> will create a <code>InputMap</code>
! * in its <code>createValue</code>
* method. The bindings are passed in the constructor.
* The bindings are an array with
! * the even number entries being string <code>KeyStrokes</code>
* (eg "alt SPACE") and
* the odd number entries being the value to use in the
! * <code>InputMap</code> (and the key in the <code>ActionMap</code>).
* @since 1.3
*/
public static class LazyInputMap implements LazyValue {
/** Key bindings are registered under. */
private Object[] bindings;
--- 1175,1192 ----
}
}
/**
! * {@code LazyInputMap} will create a {@code InputMap}
! * in its {@code createValue}
* method. The bindings are passed in the constructor.
* The bindings are an array with
! * the even number entries being string {@code KeyStrokes}
* (eg "alt SPACE") and
* the odd number entries being the value to use in the
! * {@code InputMap} (and the key in the {@code ActionMap}).
* @since 1.3
*/
public static class LazyInputMap implements LazyValue {
/** Key bindings are registered under. */
private Object[] bindings;
*** 1198,1212 ****
public LazyInputMap(Object[] bindings) {
this.bindings = bindings;
}
/**
! * Creates an <code>InputMap</code> with the bindings that are
* passed in.
*
! * @param table a <code>UIDefaults</code> table
! * @return the <code>InputMap</code>
*/
public Object createValue(UIDefaults table) {
if (bindings != null) {
InputMap km = LookAndFeel.makeInputMap(bindings);
return km;
--- 1198,1212 ----
public LazyInputMap(Object[] bindings) {
this.bindings = bindings;
}
/**
! * Creates an {@code InputMap} with the bindings that are
* passed in.
*
! * @param table a {@code UIDefaults} table
! * @return the {@code InputMap}
*/
public Object createValue(UIDefaults table) {
if (bindings != null) {
InputMap km = LookAndFeel.makeInputMap(bindings);
return km;
*** 1214,1231 ****
return null;
}
}
/**
! * <code>TextAndMnemonicHashMap</code> stores swing resource strings. Many of strings
* can have a mnemonic. For example:
* FileChooser.saveButton.textAndMnemonic=&Save
* For this case method get returns "Save" for the key "FileChooser.saveButtonText" and
* mnemonic "S" for the key "FileChooser.saveButtonMnemonic"
*
* There are several patterns for the text and mnemonic suffixes which are checked by the
! * <code>TextAndMnemonicHashMap</code> class.
* Patterns which are converted to the xxx.textAndMnemonic key:
* (xxxNameText, xxxNameMnemonic)
* (xxxNameText, xxxMnemonic)
* (xxx.nameText, xxx.mnemonic)
* (xxxText, xxxMnemonic)
--- 1214,1231 ----
return null;
}
}
/**
! * {@code TextAndMnemonicHashMap} stores swing resource strings. Many of strings
* can have a mnemonic. For example:
* FileChooser.saveButton.textAndMnemonic=&Save
* For this case method get returns "Save" for the key "FileChooser.saveButtonText" and
* mnemonic "S" for the key "FileChooser.saveButtonMnemonic"
*
* There are several patterns for the text and mnemonic suffixes which are checked by the
! * {@code TextAndMnemonicHashMap} class.
* Patterns which are converted to the xxx.textAndMnemonic key:
* (xxxNameText, xxxNameMnemonic)
* (xxxNameText, xxxMnemonic)
* (xxx.nameText, xxx.mnemonic)
* (xxxText, xxxMnemonic)
< prev index next >