FileDocCategorySizeDatePackage
UIManager.javaAPI DocJava SE 6 API56787Tue Jun 10 00:26:42 BST 2008javax.swing

UIManager

public class UIManager extends Object implements Serializable
{@code UIManager} manages the current look and feel, the set of available look and feels, {@code PropertyChangeListeners} that are notified when the look and feel changes, look and feel defaults, and convenience methods for obtaining various default values.

Specifying the look and feel

The look and feel can be specified in two distinct ways: by specifying the fully qualified name of the class for the look and feel, or by creating an instance of {@code LookAndFeel} and passing it to {@code setLookAndFeel}. The following example illustrates setting the look and feel to the system look and feel:
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
The following example illustrates setting the look and feel based on class name:
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
Once the look and feel has been changed it is imperative to invoke {@code updateUI} on all {@code JComponents}. The method {@link SwingUtilities#updateComponentTreeUI} makes it easy to apply {@code updateUI} to a containment hierarchy. Refer to it for details. The exact behavior of not invoking {@code updateUI} after changing the look and feel is unspecified. It is very possible to receive unexpected exceptions, painting problems, or worse.

Default look and feel

The class used for the default look and feel is chosen in the following manner:
  1. If the system property swing.defaultlaf is {@code non-null}, use its value as the default look and feel class name.
  2. If the {@link java.util.Properties} file swing.properties exists and contains the key swing.defaultlaf, use its value as the default look and feel class name. The location that is checked for swing.properties may vary depending upon the implementation of the Java platform. In Sun's implementation the location is ${java.home}/lib/swing.properties. Refer to the release notes of the implementation being used for further details.
  3. Otherwise use the cross platform look and feel.

Defaults

{@code UIManager} manages three sets of {@code UIDefaults}. In order, they are:
  1. Developer defaults. With few exceptions Swing does not alter the developer defaults; these are intended to be modified and used by the developer.
  2. Look and feel defaults. The look and feel defaults are supplied by the look and feel at the time it is installed as the current look and feel ({@code setLookAndFeel()} is invoked). The look and feel defaults can be obtained using the {@code getLookAndFeelDefaults()} method.
  3. Sytem defaults. The system defaults are provided by Swing.
Invoking any of the various {@code get} methods results in checking each of the defaults, in order, returning the first {@code non-null} value. For example, invoking {@code UIManager.getString("Table.foreground")} results in first checking developer defaults. If the developer defaults contain a value for {@code "Table.foreground"} it is returned, otherwise the look and feel defaults are checked, followed by the system defaults.

It's important to note that {@code getDefaults} returns a custom instance of {@code UIDefaults} with this resolution logic built into it. For example, {@code UIManager.getDefaults().getString("Table.foreground")} is equivalent to {@code UIManager.getString("Table.foreground")}. Both resolve using the algorithm just described. In many places the documentation uses the word defaults to refer to the custom instance of {@code UIDefaults} with the resolution logic as previously described.

When the look and feel is changed, {@code UIManager} alters only the look and feel defaults; the developer and system defaults are not altered by the {@code UIManager} in any way.

The set of defaults a particular look and feel supports is defined and documented by that look and feel. In addition, each look and feel, or {@code ComponentUI} provided by a look and feel, may access the defaults at different times in their life cycle. Some look and feels may agressively look up defaults, so that changing a default may not have an effect after installing the look and feel. Other look and feels may lazily access defaults so that a change to the defaults may effect an existing look and feel. Finally, other look and feels might not configure themselves from the defaults table in any way. None-the-less it is usually the case that a look and feel expects certain defaults, so that in general a {@code ComponentUI} provided by one look and feel will not work with another look and feel.

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 {@link java.beans.XMLEncoder}.

version
1.126 07/10/06
author
Thomas Ball
author
Hans Muller

Fields Summary
private static final Object
classLock
private static Thread
currentLAFStateThread
private static LAFState
currentLAFState
private static final String
defaultLAFKey
private static final String
auxiliaryLAFsKey
private static final String
multiplexingLAFKey
private static final String
installedLAFsKey
private static final String
disableMnemonicKey
private static LookAndFeelInfo[]
installedLAFs
The default value of installedLAFS is used when no swing.properties file is available or if the file doesn't contain a "swing.installedlafs" property.
Constructors Summary
Methods Summary
public static voidaddAuxiliaryLookAndFeel(javax.swing.LookAndFeel laf)
Adds a LookAndFeel to the list of auxiliary look and feels. The auxiliary look and feels tell the multiplexing look and feel what other LookAndFeel classes for a component instance are to be used in addition to the default LookAndFeel class when creating a multiplexing UI. The change will only take effect when a new UI class is created or when the default look and feel is changed on a component instance.

Note these are not the same as the installed look and feels.

param
laf the LookAndFeel object
see
#removeAuxiliaryLookAndFeel
see
#setLookAndFeel
see
#getAuxiliaryLookAndFeels
see
#getInstalledLookAndFeels

        maybeInitialize();

        if (!laf.isSupportedLookAndFeel()) {
            // Ideally we would throw an exception here, but it's too late
            // for that.
            return;
        }
        Vector v = getLAFState().auxLookAndFeels;
        if (v == null) {
            v = new Vector();
        } 

	if (!v.contains(laf)) {
	    v.addElement(laf);
	    laf.initialize();
            getLAFState().auxLookAndFeels = v;

	    if (getLAFState().multiLookAndFeel == null) {
	        getLAFState().multiLookAndFeel = getMultiLookAndFeel();
            }
	}
    
public static voidaddPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. The listener is registered for all properties.

param
listener the PropertyChangeListener to be added
see
java.beans.PropertyChangeSupport

	synchronized (classLock) {
	    getLAFState().getPropertyChangeSupport(true).
                             addPropertyChangeListener(listener);
	}
    
private static voidcheckProperty(java.util.Properties props, java.lang.String key)

        // No need to do catch the SecurityException here, this runs
        // in a doPrivileged.
        String value = System.getProperty(key);
        if (value != null) {
            props.put(key, value);
        }
    
public static java.lang.Objectget(java.lang.Object key)
Returns an object from the defaults.

param
key an Object specifying the desired object
return
the Object
throws
NullPointerException if {@code key} is {@code null}

 
        return getDefaults().get(key); 
    
public static java.lang.Objectget(java.lang.Object key, java.util.Locale l)
Returns an object from the defaults that is appropriate for the given locale.

param
key an Object specifying the desired object
param
l the Locale for which the object is desired; refer to {@code UIDefaults} for details on how a {@code null} {@code Locale} is handled
return
the Object
throws
NullPointerException if {@code key} is {@code null}
since
1.4

 
        return getDefaults().get(key,l); 
    
public static javax.swing.LookAndFeel[]getAuxiliaryLookAndFeels()
Returns the list of auxiliary look and feels (can be null). The auxiliary look and feels tell the multiplexing look and feel what other LookAndFeel classes for a component instance are to be used in addition to the default LookAndFeel class when creating a multiplexing UI.

Note these are not the same as the installed look and feels.

return
list of auxiliary LookAndFeels or null
see
#addAuxiliaryLookAndFeel
see
#removeAuxiliaryLookAndFeel
see
#setLookAndFeel
see
#getInstalledLookAndFeels

        maybeInitialize();

        Vector v = getLAFState().auxLookAndFeels;
        if ((v == null) || (v.size() == 0)) {
            return null;
        } 
        else {
            LookAndFeel[] rv = new LookAndFeel[v.size()];
            for (int i = 0; i < rv.length; i++) {
                rv[i] = (LookAndFeel)v.elementAt(i);
            }
            return rv;
        }
    
public static booleangetBoolean(java.lang.Object key)
Returns a boolean from the defaults which is associated with the key value. If the key is not found or the key doesn't represent a boolean value then {@code false} is returned.

param
key an Object specifying the key for the desired boolean value
return
the boolean value corresponding to the key
throws
NullPointerException if {@code key} is {@code null}
since
1.4

        return getDefaults().getBoolean(key);
    
public static booleangetBoolean(java.lang.Object key, java.util.Locale l)
Returns a boolean from the defaults which is associated with the key value and the given Locale. If the key is not found or the key doesn't represent a boolean value then {@code false} will be returned.

param
key an Object specifying the key for the desired boolean value
param
l the Locale for which the boolean is desired; refer to {@code UIDefaults} for details on how a {@code null} {@code Locale} is handled
return
the boolean value corresponding to the key
throws
NullPointerException if {@code key} is {@code null}
since
1.4

        return getDefaults().getBoolean(key,l);
    
public static javax.swing.border.BordergetBorder(java.lang.Object key)
Returns a border from the defaults. If the value for {@code key} is not a {@code Border}, {@code null} is returned.

param
key an Object specifying the border
return
the Border object
throws
NullPointerException if {@code key} is {@code null}

 
        return getDefaults().getBorder(key); 
    
public static javax.swing.border.BordergetBorder(java.lang.Object key, java.util.Locale l)
Returns a border from the defaults that is appropriate for the given locale. If the value for {@code key} is not a {@code Border}, {@code null} is returned.

param
key an Object specifying the border
param
l the Locale for which the border is desired; refer to {@code UIDefaults} for details on how a {@code null} {@code Locale} is handled
return
the Border object
throws
NullPointerException if {@code key} is {@code null}
since
1.4

 
        return getDefaults().getBorder(key,l); 
    
public static java.awt.ColorgetColor(java.lang.Object key)
Returns a color from the defaults. If the value for {@code key} is not a {@code Color}, {@code null} is returned.

param
key an Object specifying the color
return
the Color object
throws
NullPointerException if {@code key} is {@code null}

 
        return getDefaults().getColor(key); 
    
public static java.awt.ColorgetColor(java.lang.Object key, java.util.Locale l)
Returns a color from the defaults that is appropriate for the given locale. If the value for {@code key} is not a {@code Color}, {@code null} is returned.

param
key an Object specifying the color
param
l the Locale for which the color is desired; refer to {@code UIDefaults} for details on how a {@code null} {@code Locale} is handled
return
the Color object
throws
NullPointerException if {@code key} is {@code null}
since
1.4

 
        return getDefaults().getColor(key,l); 
    
public static java.lang.StringgetCrossPlatformLookAndFeelClassName()
Returns the name of the LookAndFeel class that implements the default cross platform look and feel -- the Java Look and Feel (JLF). This value can be overriden by setting the swing.crossplatformlaf system property.

return
a string with the JLF implementation-class
see
#setLookAndFeel
see
#getSystemLookAndFeelClassName

	String laf = (String)AccessController.doPrivileged(
                             new GetPropertyAction("swing.crossplatformlaf"));
        if (laf != null) {
            return laf;
        }
        return "javax.swing.plaf.metal.MetalLookAndFeel";
    
public static javax.swing.UIDefaultsgetDefaults()
Returns the defaults. The returned defaults resolve using the logic specified in the class documentation.

return
a UIDefaults object containing the default values

        maybeInitialize();
        return getLAFState().multiUIDefaults;
    
public static java.awt.DimensiongetDimension(java.lang.Object key)
Returns a dimension from the defaults. If the value for {@code key} is not a {@code Dimension}, {@code null} is returned.

param
key an Object specifying the dimension object
return
the Dimension object
throws
NullPointerException if {@code key} is {@code null}

        return getDefaults().getDimension(key);
    
public static java.awt.DimensiongetDimension(java.lang.Object key, java.util.Locale l)
Returns a dimension from the defaults that is appropriate for the given locale. If the value for {@code key} is not a {@code Dimension}, {@code null} is returned.

param
key an Object specifying the dimension object
param
l the Locale for which the object is desired; refer to {@code UIDefaults} for details on how a {@code null} {@code Locale} is handled
return
the Dimension object
throws
NullPointerException if {@code key} is {@code null}
since
1.4

        return getDefaults().getDimension(key,l);
    
public static java.awt.FontgetFont(java.lang.Object key)
Returns a font from the defaults. If the value for {@code key} is not a {@code Font}, {@code null} is returned.

param
key an Object specifying the font
return
the Font object
throws
NullPointerException if {@code key} is {@code null}

 
        return getDefaults().getFont(key); 
    
public static java.awt.FontgetFont(java.lang.Object key, java.util.Locale l)
Returns a font from the defaults that is appropriate for the given locale. If the value for {@code key} is not a {@code Font}, {@code null} is returned.

param
key an Object specifying the font
param
l the Locale for which the font is desired; refer to {@code UIDefaults} for details on how a {@code null} {@code Locale} is handled
return
the Font object
throws
NullPointerException if {@code key} is {@code null}
since
1.4

 
        return getDefaults().getFont(key,l); 
    
public static javax.swing.IcongetIcon(java.lang.Object key)
Returns an Icon from the defaults. If the value for {@code key} is not an {@code Icon}, {@code null} is returned.

param
key an Object specifying the icon
return
the Icon object
throws
NullPointerException if {@code key} is {@code null}

 
        return getDefaults().getIcon(key); 
    
public static javax.swing.IcongetIcon(java.lang.Object key, java.util.Locale l)
Returns an Icon from the defaults that is appropriate for the given locale. If the value for {@code key} is not an {@code Icon}, {@code null} is returned.

param
key an Object specifying the icon
param
l the Locale for which the icon is desired; refer to {@code UIDefaults} for details on how a {@code null} {@code Locale} is handled
return
the Icon object
throws
NullPointerException if {@code key} is {@code null}
since
1.4

 
        return getDefaults().getIcon(key,l); 
    
public static java.awt.InsetsgetInsets(java.lang.Object key)
Returns an Insets object from the defaults. If the value for {@code key} is not an {@code Insets}, {@code null} is returned.

param
key an Object specifying the Insets object
return
the Insets object
throws
NullPointerException if {@code key} is {@code null}

        return getDefaults().getInsets(key);
    
public static java.awt.InsetsgetInsets(java.lang.Object key, java.util.Locale l)
Returns an Insets object from the defaults that is appropriate for the given locale. If the value for {@code key} is not an {@code Insets}, {@code null} is returned.

param
key an Object specifying the Insets object
param
l the Locale for which the object is desired; refer to {@code UIDefaults} for details on how a {@code null} {@code Locale} is handled
return
the Insets object
throws
NullPointerException if {@code key} is {@code null}
since
1.4

        return getDefaults().getInsets(key,l);
    
public static javax.swing.UIManager$LookAndFeelInfo[]getInstalledLookAndFeels()
Returns an array of {@code LookAndFeelInfo}s representing the {@code LookAndFeel} implementations currently available. The LookAndFeelInfo objects can be used by an application to construct a menu of look and feel options for the user, or to determine which look and feel to set at startup time. To avoid the penalty of creating numerous {@code LookAndFeel} objects, {@code LookAndFeelInfo} maintains the class name of the {@code LookAndFeel} class, not the actual {@code LookAndFeel} instance.

The following example illustrates setting the current look and feel from an instance of {@code LookAndFeelInfo}:

UIManager.setLookAndFeel(info.getClassName());

return
an array of LookAndFeelInfo objects
see
#setLookAndFeel

        ArrayList iLAFs = new ArrayList(4);
        iLAFs.add(new LookAndFeelInfo(
                      "Metal", "javax.swing.plaf.metal.MetalLookAndFeel"));
        iLAFs.add(new LookAndFeelInfo("CDE/Motif",
                  "com.sun.java.swing.plaf.motif.MotifLookAndFeel"));

        // Only include windows on Windows boxs.
	String osName = (String)AccessController.doPrivileged(
                             new GetPropertyAction("os.name"));
        if (osName != null && osName.indexOf("Windows") != -1) {
            iLAFs.add(new LookAndFeelInfo("Windows",
                        "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"));
            if (Toolkit.getDefaultToolkit().getDesktopProperty(
                    "win.xpstyle.themeActive") != null) {
                iLAFs.add(new LookAndFeelInfo("Windows Classic",
                 "com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel"));
            }
        }
        else {
            // GTK is not shipped on Windows.
            iLAFs.add(new LookAndFeelInfo("GTK+",
                  "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"));
        }
        installedLAFs = (LookAndFeelInfo[])iLAFs.toArray(
                        new LookAndFeelInfo[iLAFs.size()]);
    
        maybeInitialize();
        LookAndFeelInfo[] ilafs = installedLAFs;
        LookAndFeelInfo[] rv = new LookAndFeelInfo[ilafs.length];
        System.arraycopy(ilafs, 0, rv, 0, ilafs.length);
        return rv;
    
public static intgetInt(java.lang.Object key)
Returns an integer from the defaults. If the value for {@code key} is not an {@code Integer}, or does not exist, {@code 0} is returned.

param
key an Object specifying the int
return
the int
throws
NullPointerException if {@code key} is {@code null}

        return getDefaults().getInt(key);
    
public static intgetInt(java.lang.Object key, java.util.Locale l)
Returns an integer from the defaults that is appropriate for the given locale. If the value for {@code key} is not an {@code Integer}, or does not exist, {@code 0} is returned.

param
key an Object specifying the int
param
l the Locale for which the int is desired; refer to {@code UIDefaults} for details on how a {@code null} {@code Locale} is handled
return
the int
throws
NullPointerException if {@code key} is {@code null}
since
1.4

        return getDefaults().getInt(key,l);
    
private static javax.swing.UIManager$LAFStategetLAFState()
Return the LAFState object, lazily create one if necessary. All access to the LAFState fields is done via this method, for example:
getLAFState().initialized = true;



                                        
        
	// First check whether we're running on the same thread as
	// the last request.
	Thread thisThread = Thread.currentThread();
	if (thisThread == currentLAFStateThread) {
	    return currentLAFState;
	}

        LAFState rv = (LAFState)SwingUtilities.appContextGet(
                SwingUtilities2.LAF_STATE_KEY);
        if (rv == null) {
	    synchronized (classLock) {
                rv = (LAFState)SwingUtilities.appContextGet(
                        SwingUtilities2.LAF_STATE_KEY);
		if (rv == null) {
                    SwingUtilities.appContextPut(
                            SwingUtilities2.LAF_STATE_KEY, 
                            (rv = new LAFState()));
		}
	    }
        }

	currentLAFStateThread = thisThread;
	currentLAFState = rv;

	return rv;
    
public static javax.swing.LookAndFeelgetLookAndFeel()
Returns the current look and feel or null.

return
current look and feel, or null
see
#setLookAndFeel

        maybeInitialize();
        return getLAFState().lookAndFeel;
    
public static javax.swing.UIDefaultsgetLookAndFeelDefaults()
Returns the {@code UIDefaults} from the current look and feel, that were obtained at the time the look and feel was installed.

In general, developers should use the {@code UIDefaults} returned from {@code getDefaults()}. As the current look and feel may expect certain values to exist, altering the {@code UIDefaults} returned from this method could have unexpected results.

return
UIDefaults from the current look and feel
see
#getDefaults
see
#setLookAndFeel(LookAndFeel)
see
LookAndFeel#getDefaults

        maybeInitialize();
        return getLAFState().getLookAndFeelDefaults();
    
private static javax.swing.LookAndFeelgetMultiLookAndFeel()
Finds the Multiplexing LookAndFeel.

	LookAndFeel multiLookAndFeel = getLAFState().multiLookAndFeel;
	if (multiLookAndFeel == null) {
            String defaultName = "javax.swing.plaf.multi.MultiLookAndFeel";
            String className = getLAFState().swingProps.getProperty(multiplexingLAFKey, defaultName);
            try {
                Class lnfClass = SwingUtilities.loadSystemClass(className);
                multiLookAndFeel = (LookAndFeel)lnfClass.newInstance();
            } catch (Exception exc) {
                System.err.println("UIManager: failed loading " + className);
            }
	}
	return multiLookAndFeel;
    
public static java.beans.PropertyChangeListener[]getPropertyChangeListeners()
Returns an array of all the PropertyChangeListeners added to this UIManager with addPropertyChangeListener().

return
all of the PropertyChangeListeners added or an empty array if no listeners have been added
since
1.4

        synchronized(classLock) {
            return getLAFState().getPropertyChangeSupport(true).
                      getPropertyChangeListeners();
        }
    
public static java.lang.StringgetString(java.lang.Object key)
Returns a string from the defaults. If the value for {@code key} is not a {@code String}, {@code null} is returned.

param
key an Object specifying the string
return
the String
throws
NullPointerException if {@code key} is {@code null}

 
        return getDefaults().getString(key); 
    
public static java.lang.StringgetString(java.lang.Object key, java.util.Locale l)
Returns a string from the defaults that is appropriate for the given locale. If the value for {@code key} is not a {@code String}, {@code null} is returned.

param
key an Object specifying the string
param
l the Locale for which the string is desired; refer to {@code UIDefaults} for details on how a {@code null} {@code Locale} is handled
return
the String
since
1.4
throws
NullPointerException if {@code key} is {@code null}

 
        return getDefaults().getString(key,l); 
    
static java.lang.StringgetString(java.lang.Object key, java.awt.Component c)
Returns a string from the defaults that is appropriate for the given locale. If the value for {@code key} is not a {@code String}, {@code null} is returned.

param
key an Object specifying the string
param
c {@code Component} used to determine the locale; {@code null} implies the default locale as returned by {@code Locale.getDefault()}
return
the String
throws
NullPointerException if {@code key} is {@code null}

 
        Locale l = (c == null) ? Locale.getDefault() : c.getLocale();
        return getString(key, l);
    
public static java.lang.StringgetSystemLookAndFeelClassName()
Returns the name of the LookAndFeel class that implements the native system look and feel if there is one, otherwise the name of the default cross platform LookAndFeel class. This value can be overriden by setting the swing.systemlaf system property.

return
the String of the LookAndFeel class
see
#setLookAndFeel
see
#getCrossPlatformLookAndFeelClassName

	String systemLAF = (String)AccessController.doPrivileged(
                             new GetPropertyAction("swing.systemlaf"));
        if (systemLAF != null) {
            return systemLAF;
        }
	String osName = (String)AccessController.doPrivileged(
                             new GetPropertyAction("os.name"));

        if (osName != null) {
            if (osName.indexOf("Windows") != -1) {
                return "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
            }
            else {
                String desktop = (String)AccessController.doPrivileged(
                             new GetPropertyAction("sun.desktop"));
                if ("gnome".equals(desktop)) {
                    // May be set on Linux and Solaris boxs.
                    return "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
                }
                if ((osName.indexOf("Solaris") != -1) || 
		             (osName.indexOf("SunOS") != -1)) {
                    return "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
                }
            }
        }
        return getCrossPlatformLookAndFeelClassName();
    
public static javax.swing.plaf.ComponentUIgetUI(javax.swing.JComponent target)
Returns the appropriate {@code ComponentUI} implementation for {@code target}. Typically, this is a cover for {@code getDefaults().getUI(target)}. However, if an auxiliary look and feel has been installed, this first invokes {@code getUI(target)} on the multiplexing look and feel's defaults, and returns that value if it is {@code non-null}.

param
target the JComponent to return the {@code ComponentUI} for
return
the ComponentUI object for {@code target}
throws
NullPointerException if {@code target} is {@code null}
see
UIDefaults#getUI

        maybeInitialize();
        ComponentUI ui = null;
        LookAndFeel multiLAF = getLAFState().multiLookAndFeel;
        if (multiLAF != null) {
            // This can return null if the multiplexing look and feel
            // doesn't support a particular UI.
            ui = multiLAF.getDefaults().getUI(target);
        }
        if (ui == null) {
            ui = getDefaults().getUI(target);
        }
        return ui;
    
private static voidinitialize()

        Properties swingProps = loadSwingProperties();
        initializeSystemDefaults(swingProps);
        initializeDefaultLAF(swingProps);
        initializeAuxiliaryLAFs(swingProps);
        initializeInstalledLAFs(swingProps);

        // Enable the Swing default LayoutManager.
        String toolkitName = Toolkit.getDefaultToolkit().getClass().getName();
        // don't set default policy if this is XAWT.
        if (!"sun.awt.X11.XToolkit".equals(toolkitName)) {
            if (FocusManager.isFocusManagerEnabled()) {
                KeyboardFocusManager.getCurrentKeyboardFocusManager().
                    setDefaultFocusTraversalPolicy(
                        new LayoutFocusTraversalPolicy());
            }
        }

        // Install Swing's PaintEventDispatcher
        if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
            sun.awt.PaintEventDispatcher.setPaintEventDispatcher(
                                        new SwingPaintEventDispatcher());
        }
        // Install a hook that will be invoked if no one consumes the
        // KeyEvent.  If the source isn't a JComponent this will process
        // key bindings, if the source is a JComponent it implies that
        // processKeyEvent was already invoked and thus no need to process
        // the bindings again, unless the Component is disabled, in which
        // case KeyEvents will no longer be dispatched to it so that we
        // handle it here.
        KeyboardFocusManager.getCurrentKeyboardFocusManager().
                addKeyEventPostProcessor(new KeyEventPostProcessor() {
                    public boolean postProcessKeyEvent(KeyEvent e) {
                        Component c = e.getComponent();

                        if ((!(c instanceof JComponent) ||
                             (c != null && !((JComponent)c).isEnabled())) &&
                                JComponent.KeyboardState.shouldProcess(e) &&
                                SwingUtilities.processKeyBindings(e)) {
                            e.consume();
                            return true;
                        }
                        return false;
                    }
                });
        try {
            Method setRequestFocusControllerM = java.security.AccessController.doPrivileged(
                    new java.security.PrivilegedExceptionAction<Method>() {
                        public Method run() throws Exception {
                            Method method =
                            Component.class.getDeclaredMethod("setRequestFocusController",
                                                              sun.awt.RequestFocusController.class);
                            method.setAccessible(true);
                            return method;
                        }
                    });
            setRequestFocusControllerM.invoke(null, JComponent.focusController);
        } catch (Exception e) {
            // perhaps we should log this
            assert false;
        }
    
private static voidinitializeAuxiliaryLAFs(java.util.Properties swingProps)

        String auxLookAndFeelNames = swingProps.getProperty(auxiliaryLAFsKey);
        if (auxLookAndFeelNames == null) {
            return;
        }

        Vector auxLookAndFeels = new Vector();

        StringTokenizer p = new StringTokenizer(auxLookAndFeelNames,",");
        String factoryName;

        /* Try to load each LookAndFeel subclass in the list.
         */

        while (p.hasMoreTokens()) {
            String className = p.nextToken();
            try {
                Class lnfClass = SwingUtilities.loadSystemClass(className);
		LookAndFeel newLAF = (LookAndFeel)lnfClass.newInstance();
		newLAF.initialize();
                auxLookAndFeels.addElement(newLAF);
            } 
            catch (Exception e) {
                System.err.println("UIManager: failed loading auxiliary look and feel " + className);
            }
        }

        /* If there were problems and no auxiliary look and feels were 
         * loaded, make sure we reset auxLookAndFeels to null.
         * Otherwise, we are going to use the MultiLookAndFeel to get
         * all component UI's, so we need to load it now.
         */
        if (auxLookAndFeels.size() == 0) {
            auxLookAndFeels = null;
        } 
        else {
	    getLAFState().multiLookAndFeel = getMultiLookAndFeel();
	    if (getLAFState().multiLookAndFeel == null) {
                auxLookAndFeels = null;
	    }
        }

        getLAFState().auxLookAndFeels = auxLookAndFeels;
    
private static voidinitializeDefaultLAF(java.util.Properties swingProps)
If the user has specified a default look and feel, use that. Otherwise use the look and feel that's native to this platform. If this code is called after the application has explicitly set it's look and feel, do nothing.

see
#maybeInitialize

        if (getLAFState().lookAndFeel != null) {
            return;
        }

        String metalLnf = getCrossPlatformLookAndFeelClassName();
        String lnfDefault = metalLnf;

        String lnfName = "<undefined>" ;
        try {
            lnfName = swingProps.getProperty(defaultLAFKey, lnfDefault);
            setLookAndFeel(lnfName);
        } catch (Exception e) {
            try {
                lnfName = swingProps.getProperty(defaultLAFKey, metalLnf);
                setLookAndFeel(lnfName);
            } catch (Exception e2) {
                throw new Error("can't load " + lnfName);
            }
        }
    
private static voidinitializeInstalledLAFs(java.util.Properties swingProps)
If a swing.properties file exist and it has a swing.installedlafs property then initialize the installedLAFs field.

see
#getInstalledLookAndFeels

        String ilafsString = swingProps.getProperty(installedLAFsKey);
        if (ilafsString == null) {
            return;
        }

        /* Create a vector that contains the value of the swing.installedlafs
         * property.  For example given "swing.installedlafs=motif,windows"
         * lafs = {"motif", "windows"}.
         */
        Vector lafs = new Vector();
        StringTokenizer st = new StringTokenizer(ilafsString, ",", false);
        while (st.hasMoreTokens()) {
            lafs.addElement(st.nextToken());
        }

        /* Look up the name and class for each name in the "swing.installedlafs"
         * list.  If they both exist then add a LookAndFeelInfo to 
         * the installedLafs array.
         */
        Vector ilafs = new Vector(lafs.size());
        for(int i = 0; i < lafs.size(); i++) {
            String laf = (String)lafs.elementAt(i);
            String name = swingProps.getProperty(makeInstalledLAFKey(laf, "name"), laf);
            String cls = swingProps.getProperty(makeInstalledLAFKey(laf, "class"));
            if (cls != null) {
                ilafs.addElement(new LookAndFeelInfo(name, cls));
            }
        }

        installedLAFs = new LookAndFeelInfo[ilafs.size()];
        for(int i = 0; i < ilafs.size(); i++) {
            installedLAFs[i] = (LookAndFeelInfo)(ilafs.elementAt(i));
        }
    
private static voidinitializeSystemDefaults(java.util.Properties swingProps)

	getLAFState().swingProps = swingProps;
    
public static voidinstallLookAndFeel(javax.swing.UIManager$LookAndFeelInfo info)
Adds the specified look and feel to the set of available look and feels. While this method allows a {@code null} {@code info}, it is strongly recommended that a {@code non-null} value be used.

param
info a LookAndFeelInfo object that names the look and feel and identifies the class that implements it
see
#setInstalledLookAndFeels

        LookAndFeelInfo[] infos = getInstalledLookAndFeels();
        LookAndFeelInfo[] newInfos = new LookAndFeelInfo[infos.length + 1];
        System.arraycopy(infos, 0, newInfos, 0, infos.length);
        newInfos[infos.length] = info;
        setInstalledLookAndFeels(newInfos);
    
public static voidinstallLookAndFeel(java.lang.String name, java.lang.String className)
Adds the specified look and feel to the set of available look and feels. While this method does not check the arguments in any way, it is strongly recommended that {@code non-null} values be supplied.

param
name descriptive name of the look and feel
param
className name of the class that implements the look and feel
see
#setInstalledLookAndFeels

        installLookAndFeel(new LookAndFeelInfo(name, className));
    
private static java.util.PropertiesloadSwingProperties()

	/* Don't bother checking for Swing properties if untrusted, as
	 * there's no way to look them up without triggering SecurityExceptions.
	 */
        if (UIManager.class.getClassLoader() != null) {
	    return new Properties();
	}
	else {
	    final Properties props = new Properties();

            java.security.AccessController.doPrivileged(
                new java.security.PrivilegedAction() {
                public Object run() {
		    try {
			File file = new File(makeSwingPropertiesFilename());

                        if (file.exists()) {
                            // InputStream has been buffered in Properties
                            // class
                            FileInputStream ins = new FileInputStream(file);
                            props.load(ins);
                            ins.close();
                        }
		    } 
		    catch (Exception e) {
			// No such file, or file is otherwise non-readable.
		    }

		    // Check whether any properties were overridden at the
		    // command line.
		    checkProperty(props, defaultLAFKey);
		    checkProperty(props, auxiliaryLAFsKey);
		    checkProperty(props, multiplexingLAFKey);
		    checkProperty(props, installedLAFsKey);
		    checkProperty(props, disableMnemonicKey);
                    // Don't care about return value.
                    return null;
		}
	    });
	    return props;
	}
    
private static java.lang.StringmakeInstalledLAFKey(java.lang.String laf, java.lang.String attr)
Return a swing.properties file key for the attribute of specified look and feel. The attr is either "name" or "class", a typical key would be: "swing.installedlaf.windows.name"


                                     
           
        return "swing.installedlaf." + laf + "." + attr;
    
private static java.lang.StringmakeSwingPropertiesFilename()
The filename for swing.properties is a path like this (Unix version): /lib/swing.properties. This method returns a bogus filename if java.home isn't defined.

        String sep = File.separator;
        // No need to wrap this in a doPrivileged as it's called from
        // a doPrivileged.
        String javaHome = System.getProperty("java.home");
        if (javaHome == null) {
            javaHome = "<java.home undefined>";
        }
        return javaHome + sep + "lib" + sep + "swing.properties";
    
private static voidmaybeInitialize()

	synchronized (classLock) {
	    if (!getLAFState().initialized) {
		getLAFState().initialized = true;
		initialize();
	    }
        }
    
public static java.lang.Objectput(java.lang.Object key, java.lang.Object value)
Stores an object in the developer defaults. This is a cover method for {@code getDefaults().put(key, value)}. This only effects the developer defaults, not the system or look and feel defaults.

param
key an Object specifying the retrieval key
param
value the Object to store; refer to {@code UIDefaults} for details on how {@code null} is handled
return
the Object returned by {@link UIDefaults#put}
throws
NullPointerException if {@code key} is {@code null}
see
UIDefaults#put

 
        return getDefaults().put(key, value); 
    
public static booleanremoveAuxiliaryLookAndFeel(javax.swing.LookAndFeel laf)
Removes a LookAndFeel from the list of auxiliary look and feels. The auxiliary look and feels tell the multiplexing look and feel what other LookAndFeel classes for a component instance are to be used in addition to the default LookAndFeel class when creating a multiplexing UI. The change will only take effect when a new UI class is created or when the default look and feel is changed on a component instance.

Note these are not the same as the installed look and feels.

return
true if the LookAndFeel was removed from the list
see
#removeAuxiliaryLookAndFeel
see
#getAuxiliaryLookAndFeels
see
#setLookAndFeel
see
#getInstalledLookAndFeels

        maybeInitialize();

	boolean result;

        Vector v = getLAFState().auxLookAndFeels;
        if ((v == null) || (v.size() == 0)) {
            return false;
        } 
	
	result = v.removeElement(laf);
	if (result) {
	    if (v.size() == 0) {
	        getLAFState().auxLookAndFeels = null;
	        getLAFState().multiLookAndFeel = null;
	    } else {
	        getLAFState().auxLookAndFeels = v;
            }
        }
	laf.uninitialize();

	return result;
    
public static voidremovePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.

param
listener the PropertyChangeListener to be removed
see
java.beans.PropertyChangeSupport

        synchronized (classLock) {
	    getLAFState().getPropertyChangeSupport(true).
                          removePropertyChangeListener(listener);
	}
    
public static voidsetInstalledLookAndFeels(javax.swing.UIManager$LookAndFeelInfo[] infos)
Sets the set of available look and feels. While this method does not check to ensure all of the {@code LookAndFeelInfos} are {@code non-null}, it is strongly recommended that only {@code non-null} values are supplied in the {@code infos} array.

param
infos set of LookAndFeelInfo objects specifying the available look and feels
see
#getInstalledLookAndFeels
throws
NullPointerException if {@code infos} is {@code null}

        LookAndFeelInfo[] newInfos = new LookAndFeelInfo[infos.length];
        System.arraycopy(infos, 0, newInfos, 0, infos.length);
        installedLAFs = newInfos;
    
public static voidsetLookAndFeel(java.lang.String className)
Loads the {@code LookAndFeel} specified by the given class name, using the current thread's context class loader, and passes it to {@code setLookAndFeel(LookAndFeel)}.

param
className a string specifying the name of the class that implements the look and feel
exception
ClassNotFoundException if the LookAndFeel class could not be found
exception
InstantiationException if a new instance of the class couldn't be created
exception
IllegalAccessException if the class or initializer isn't accessible
exception
UnsupportedLookAndFeelException if lnf.isSupportedLookAndFeel() is false
throws
ClassCastException if {@code className} does not identify a class that extends {@code LookAndFeel}

        if ("javax.swing.plaf.metal.MetalLookAndFeel".equals(className)) {
            // Avoid reflection for the common case of metal.
            setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel());
        }
        else {
            Class lnfClass = SwingUtilities.loadSystemClass(className);
            setLookAndFeel((LookAndFeel)(lnfClass.newInstance()));
        }
    
public static voidsetLookAndFeel(javax.swing.LookAndFeel newLookAndFeel)
Sets the current look and feel to {@code newLookAndFeel}. If the current look and feel is {@code non-null} {@code uninitialize} is invoked on it. If {@code newLookAndFeel} is {@code non-null}, {@code initialize} is invoked on it followed by {@code getDefaults}. The defaults returned from {@code newLookAndFeel.getDefaults()} replace those of the defaults from the previous look and feel. If the {@code newLookAndFeel} is {@code null}, the look and feel defaults are set to {@code null}.

A value of {@code null} can be used to set the look and feel to {@code null}. As the {@code LookAndFeel} is required for most of Swing to function, setting the {@code LookAndFeel} to {@code null} is strongly discouraged.

This is a JavaBeans bound property.

param
newLookAndFeel {@code LookAndFeel} to install
throws
UnsupportedLookAndFeelException if {@code newLookAndFeel} is {@code non-null} and {@code newLookAndFeel.isSupportedLookAndFeel()} returns {@code false}
see
#getLookAndFeel

        if ((newLookAndFeel != null) && !newLookAndFeel.isSupportedLookAndFeel()) {
            String s = newLookAndFeel.toString() + " not supported on this platform";
            throw new UnsupportedLookAndFeelException(s);
        }

        LAFState lafState = getLAFState();
        LookAndFeel oldLookAndFeel = lafState.lookAndFeel;
        if (oldLookAndFeel != null) {
            oldLookAndFeel.uninitialize();
        }

        lafState.lookAndFeel = newLookAndFeel;
        if (newLookAndFeel != null) {
            sun.swing.DefaultLookup.setDefaultLookup(null);
            newLookAndFeel.initialize();
            lafState.setLookAndFeelDefaults(newLookAndFeel.getDefaults());
        }
        else {
            lafState.setLookAndFeelDefaults(null);
        }

        SwingPropertyChangeSupport changeSupport = lafState.
                                         getPropertyChangeSupport(false);
        if (changeSupport != null) {
            changeSupport.firePropertyChange("lookAndFeel", oldLookAndFeel,
                                             newLookAndFeel);
        }