/* * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package javax.swing; import javax.swing.plaf.ComponentUI;import javax.swing.border.*;import javax.swing.event.SwingPropertyChangeSupport; import java.lang.reflect.*;import java.util.HashMap;import java.util.Map;import java.util.Enumeration;import java.util.Hashtable;import java.util.ResourceBundle;import java.util.ResourceBundle.Control;import java.util.Locale;import java.util.Vector;import java.util.MissingResourceException;import java.awt.Font;import java.awt.Color;import java.awt.Insets;import java.awt.Dimension;import java.lang.reflect.Method;import java.beans.PropertyChangeListener;import java.beans.PropertyChangeEvent;import java.security.AccessController;import java.security.AccessControlContext;import java.security.PrivilegedAction; import sun.reflect.misc.MethodUtil;import sun.reflect.misc.ReflectUtil;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<sup><font size="-2">TM</font></sup> * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. * * @see UIManager * @author Hans Muller */public class UIDefaults extends Hashtable<Object,Object>{ private static final Object PENDING = "Pending"; private SwingPropertyChangeSupport changeSupport; private Vector<String> resourceBundles; private Locale defaultLocale = Locale.getDefault(); /** * Maps from a Locale to a cached Map of the ResourceBundle. This is done * so as to avoid an exception being thrown when a value is asked for. * Access to this should be done while holding a lock on the * UIDefaults, eg synchronized(this). */ private Map<Locale, Map<String, Object>> resourceCache; /** * Creates an empty defaults table. */ public UIDefaults() { this(700, .75f); } /** * Creates an empty defaults table with the specified initial capacity and * load factor. * * @param initialCapacity the initial capacity of the defaults table * @param loadFactor the load factor of the defaults table * @see java.util.Hashtable * @since 1.6 */ public UIDefaults(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); resourceCache = new HashMap<Locale, Map<String, Object>>(); } /** * Creates a defaults table initialized with the specified * key/value pairs. For example: * <pre> Object[] uiDefaults = { "Font", new Font("Dialog", Font.BOLD, 12), "Color", Color.red, "five", new Integer(5) } UIDefaults myDefaults = new UIDefaults(uiDefaults); * </pre> * @param keyValueList an array of objects containing the key/value * pairs */ public UIDefaults(Object[] keyValueList) { super(keyValueList.length / 2); for(int i = 0; i < keyValueList.length; i += 2) { super.put(keyValueList[i], keyValueList[i + 1]); } } /** * 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 * @since 1.4 */ public Object get(Object key) { Object value = getFromHashtable( key ); return (value != null) ? value : getFromResourceBundle(key, null); } /** * Looks up up the given key in our Hashtable and resolves LazyValues * or ActiveValues. */ private Object getFromHashtable(Object key) { /* Quickly handle the common case, without grabbing * a lock. */ Object value = super.get(key); if ((value != PENDING) && !(value instanceof ActiveValue) && !(value instanceof LazyValue)) { return value; } /* If the LazyValue for key is being constructed by another * thread then wait and then return the new value, otherwise drop * the lock and construct the ActiveValue or the LazyValue. * We use the special value PENDING to mark LazyValues that * are being constructed. */ synchronized(this) { value = super.get(key); if (value == PENDING) { do { try { this.wait(); } catch (InterruptedException e) { } value = super.get(key); } while(value == PENDING); return value; } else if (value instanceof LazyValue) { super.put(key, PENDING); } else if (!(value instanceof ActiveValue)) { return value; } } /* At this point we know that the value of key was * a LazyValue or an ActiveValue. */ if (value instanceof LazyValue) { try { /* If an exception is thrown we'll just put the LazyValue * back in the table. */ value = ((LazyValue)value).createValue(this); } finally { synchronized(this) { if (value == null) { super.remove(key); } else { super.put(key, value); } this.notifyAll(); } } } else { value = ((ActiveValue)value).createValue(this); } return value; } /** * 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 */ public Object get(Object key, Locale l) { Object value = getFromHashtable( key ); return (value != null) ? value : getFromResourceBundle(key, l); } /** * Looks up given key in our resource bundles. */ private Object getFromResourceBundle(Object key, Locale l) { if( resourceBundles == null || resourceBundles.isEmpty() || !(key instanceof String) ) { return null; } // A null locale means use the default locale. if( l == null ) { if( defaultLocale == null ) return null; else l = defaultLocale; } synchronized(this) { return getResourceCache(l).get(key); } } /** * Returns a Map of the known resources for the given locale. */ private Map<String, Object> getResourceCache(Locale l) { Map<String, Object> values = resourceCache.get(l); if (values == null) { values = new HashMap<String, Object>(); for (int i=resourceBundles.size()-1; i >= 0; i--) { String bundleName = resourceBundles.get(i); try { Control c = CoreResourceBundleControl.getRBControlInstance(bundleName); ResourceBundle b; if (c != null) { b = ResourceBundle.getBundle(bundleName, l, c); } else { b = ResourceBundle.getBundle(bundleName, l); } Enumeration keys = b.getKeys(); while (keys.hasMoreElements()) { String key = (String)keys.nextElement(); if (values.get(key) == null) { Object value = b.getObject(key); values.put(key, value); } } } catch( MissingResourceException mre ) { // Keep looking } } resourceCache.put(l, values); } 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); if (key instanceof String) { firePropertyChange((String)key, oldValue, value); } return oldValue; } /** * 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 */ public void putDefaults(Object[] keyValueList) { for(int i = 0, max = keyValueList.length; i < max; i += 2) { Object value = keyValueList[i + 1]; if (value == null) { super.remove(keyValueList[i]); } else { super.put(keyValueList[i], value); } } 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; } Lines 1–500 of 1218. Load more
/* * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package javax.swing; import javax.swing.plaf.ComponentUI; import javax.swing.border.*; import javax.swing.event.SwingPropertyChangeSupport; import java.lang.reflect.*; import java.util.HashMap; import java.util.Map; import java.util.Enumeration; import java.util.Hashtable; import java.util.ResourceBundle; import java.util.ResourceBundle.Control; import java.util.Locale; import java.util.Vector; import java.util.MissingResourceException; import java.awt.Font; import java.awt.Color; import java.awt.Insets; import java.awt.Dimension; import java.lang.reflect.Method; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeEvent; import java.security.AccessController; import java.security.AccessControlContext; import java.security.PrivilegedAction; import sun.reflect.misc.MethodUtil; import sun.reflect.misc.ReflectUtil; 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<sup><font size="-2">TM</font></sup> * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. * * @see UIManager * @author Hans Muller */ public class UIDefaults extends Hashtable<Object,Object> { private static final Object PENDING = "Pending"; private SwingPropertyChangeSupport changeSupport; private Vector<String> resourceBundles; private Locale defaultLocale = Locale.getDefault(); /** * Maps from a Locale to a cached Map of the ResourceBundle. This is done * so as to avoid an exception being thrown when a value is asked for. * Access to this should be done while holding a lock on the * UIDefaults, eg synchronized(this). */ private Map<Locale, Map<String, Object>> resourceCache; /** * Creates an empty defaults table. */ public UIDefaults() { this(700, .75f); } /** * Creates an empty defaults table with the specified initial capacity and * load factor. * * @param initialCapacity the initial capacity of the defaults table * @param loadFactor the load factor of the defaults table * @see java.util.Hashtable * @since 1.6 */ public UIDefaults(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); resourceCache = new HashMap<Locale, Map<String, Object>>(); } /** * Creates a defaults table initialized with the specified * key/value pairs. For example: * <pre> Object[] uiDefaults = { "Font", new Font("Dialog", Font.BOLD, 12), "Color", Color.red, "five", new Integer(5) } UIDefaults myDefaults = new UIDefaults(uiDefaults); * </pre> * @param keyValueList an array of objects containing the key/value * pairs */ public UIDefaults(Object[] keyValueList) { super(keyValueList.length / 2); for(int i = 0; i < keyValueList.length; i += 2) { super.put(keyValueList[i], keyValueList[i + 1]); } } /** * 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 * @since 1.4 */ public Object get(Object key) { Object value = getFromHashtable( key ); return (value != null) ? value : getFromResourceBundle(key, null); } /** * Looks up up the given key in our Hashtable and resolves LazyValues * or ActiveValues. */ private Object getFromHashtable(Object key) { /* Quickly handle the common case, without grabbing * a lock. */ Object value = super.get(key); if ((value != PENDING) && !(value instanceof ActiveValue) && !(value instanceof LazyValue)) { return value; } /* If the LazyValue for key is being constructed by another * thread then wait and then return the new value, otherwise drop * the lock and construct the ActiveValue or the LazyValue. * We use the special value PENDING to mark LazyValues that * are being constructed. */ synchronized(this) { value = super.get(key); if (value == PENDING) { do { try { this.wait(); } catch (InterruptedException e) { } value = super.get(key); } while(value == PENDING); return value; } else if (value instanceof LazyValue) { super.put(key, PENDING); } else if (!(value instanceof ActiveValue)) { return value; } } /* At this point we know that the value of key was * a LazyValue or an ActiveValue. */ if (value instanceof LazyValue) { try { /* If an exception is thrown we'll just put the LazyValue * back in the table. */ value = ((LazyValue)value).createValue(this); } finally { synchronized(this) { if (value == null) { super.remove(key); } else { super.put(key, value); } this.notifyAll(); } } } else { value = ((ActiveValue)value).createValue(this); } return value; } /** * 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 */ public Object get(Object key, Locale l) { Object value = getFromHashtable( key ); return (value != null) ? value : getFromResourceBundle(key, l); } /** * Looks up given key in our resource bundles. */ private Object getFromResourceBundle(Object key, Locale l) { if( resourceBundles == null || resourceBundles.isEmpty() || !(key instanceof String) ) { return null; } // A null locale means use the default locale. if( l == null ) { if( defaultLocale == null ) return null; else l = defaultLocale; } synchronized(this) { return getResourceCache(l).get(key); } } /** * Returns a Map of the known resources for the given locale. */ private Map<String, Object> getResourceCache(Locale l) { Map<String, Object> values = resourceCache.get(l); if (values == null) { values = new HashMap<String, Object>(); for (int i=resourceBundles.size()-1; i >= 0; i--) { String bundleName = resourceBundles.get(i); try { Control c = CoreResourceBundleControl.getRBControlInstance(bundleName); ResourceBundle b; if (c != null) { b = ResourceBundle.getBundle(bundleName, l, c); } else { b = ResourceBundle.getBundle(bundleName, l); } Enumeration keys = b.getKeys(); while (keys.hasMoreElements()) { String key = (String)keys.nextElement(); if (values.get(key) == null) { Object value = b.getObject(key); values.put(key, value); } } } catch( MissingResourceException mre ) { // Keep looking } } resourceCache.put(l, values); } 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); if (key instanceof String) { firePropertyChange((String)key, oldValue, value); } return oldValue; } /** * 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 */ public void putDefaults(Object[] keyValueList) { for(int i = 0, max = keyValueList.length; i < max; i += 2) { Object value = keyValueList[i + 1]; if (value == null) { super.remove(keyValueList[i]); } else { super.put(keyValueList[i], value); } } 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; }