javax.swing

Class UIManager

Implemented Interfaces:
Serializable

public class UIManager
extends Object
implements Serializable

Manages the current LookAndFeel and any auxiliary LookAndFeel instances.
See Also:
Serialized Form

Nested Class Summary

static class
UIManager.LookAndFeelInfo
Represents the basic information about a LookAndFeel (LAF), so that a list of installed LAFs can be presented without actually loading the LAF class(es).

Constructor Summary

UIManager()
Creates a new instance of the UIManager.

Method Summary

static void
addAuxiliaryLookAndFeel(LookAndFeel laf)
Add a LookAndFeel to the list of auxiliary look and feels.
static void
addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list.
static Object
get(Object key)
Returns an object from the UIDefaults table for the current LookAndFeel.
static Object
get(Object key, Locale locale)
Returns an object from the UIDefaults table for the current LookAndFeel.
static LookAndFeel[]
getAuxiliaryLookAndFeels()
Returns an array (possibly null) containing the auxiliary LookAndFeels that are in use.
static boolean
getBoolean(Object key)
Returns a boolean value from the defaults table, false if key is not present.
static boolean
getBoolean(Object key, Locale locale)
Returns a boolean value from the defaults table, false if key is not present.
static Border
getBorder(Object key)
Returns a border from the defaults table.
static Border
getBorder(Object key, Locale locale)
Returns a border from the defaults table.
static Color
getColor(Object key)
Returns a drawing color from the defaults table.
static Color
getColor(Object key, Locale locale)
Returns a drawing color from the defaults table.
static String
getCrossPlatformLookAndFeelClassName()
The fully qualified class name of the cross platform (Metal) look and feel.
static UIDefaults
getDefaults()
Returns the default values for this look and feel.
static Dimension
getDimension(Object key)
Returns a dimension from the defaults table.
static Dimension
getDimension(Object key, Locale locale)
Returns a dimension from the defaults table.
static Font
getFont(Object key)
Retrieves a font from the defaults table of the current LookAndFeel.
static Font
getFont(Object key, Locale locale)
Retrieves a font from the defaults table of the current LookAndFeel.
static Icon
getIcon(Object key)
Returns an Icon from the defaults table.
static Icon
getIcon(Object key, Locale locale)
Returns an Icon from the defaults table.
static Insets
getInsets(Object key)
Returns an Insets object from the defaults table.
static Insets
getInsets(Object key, Locale locale)
Returns an Insets object from the defaults table.
static UIManager.LookAndFeelInfo[]
getInstalledLookAndFeels()
Returns an array containing information about the LookAndFeels that are installed.
static int
getInt(Object key)
static int
getInt(Object key, Locale locale)
static LookAndFeel
getLookAndFeel()
Returns the current look and feel (which may be null).
static UIDefaults
getLookAndFeelDefaults()
Returns the UIDefaults table of the currently active look and feel.
static PropertyChangeListener[]
getPropertyChangeListeners()
Returns an array of all added PropertyChangeListener objects.
static String
getString(Object key)
Returns a string from the defaults table.
static String
getString(Object key, Locale locale)
Returns a string from the defaults table.
static String
getSystemLookAndFeelClassName()
Returns the name of the LookAndFeel class that implements the native systems look and feel if there is one, otherwise the name of the default cross platform LookAndFeel class.
static ComponentUI
getUI(JComponent target)
Returns UI delegate from the current LookAndFeel that renders the target component.
static void
installLookAndFeel(String name, String className)
Creates a new look and feel and adds it to the current array.
static void
installLookAndFeel(UIManager.LookAndFeelInfo info)
Adds the specified look and feel to the current array and then calls setInstalledLookAndFeels(javax.swing.UIManager.LookAndFeelInfo[]).
static Object
put(Object key, Object value)
Stores an object in the defaults table.
static boolean
removeAuxiliaryLookAndFeel(LookAndFeel laf)
Removes a LookAndFeel (LAF) from the list of auxiliary LAFs.
static void
removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list.
static void
setInstalledLookAndFeels(UIManager.LookAndFeelInfo[] infos)
Replaces the current array of installed LookAndFeelInfos.
static void
setLookAndFeel(String className)
Set the current default look and feel using a class name.
static void
setLookAndFeel(LookAndFeel newLookAndFeel)
Sets the current LookAndFeel.

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

UIManager

public UIManager()
Creates a new instance of the UIManager. There is no need to construct an instance of this class, since all methods are static.

Method Details

addAuxiliaryLookAndFeel

public static void addAuxiliaryLookAndFeel(LookAndFeel laf)
Add a LookAndFeel to the list of auxiliary look and feels.
Parameters:
laf - the auxiliary look and feel (null not permitted).
Throws:
NullPointerException - if laf is null.

addPropertyChangeListener

public static void addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list.
Parameters:
listener - the listener to add

get

public static Object get(Object key)
Returns an object from the UIDefaults table for the current LookAndFeel.
Parameters:
key - the key.
Returns:
The object.

get

public static Object get(Object key,
                         Locale locale)
Returns an object from the UIDefaults table for the current LookAndFeel.
Parameters:
key - the key.
Returns:
The object.

getAuxiliaryLookAndFeels

public static LookAndFeel[] getAuxiliaryLookAndFeels()
Returns an array (possibly null) containing the auxiliary LookAndFeels that are in use. These are used by the MultiLookAndFeel class.
Returns:
The auxiliary look and feels (possibly null).

getBoolean

public static boolean getBoolean(Object key)
Returns a boolean value from the defaults table, false if key is not present.
Since:
1.4

getBoolean

public static boolean getBoolean(Object key,
                                 Locale locale)
Returns a boolean value from the defaults table, false if key is not present.
Since:
1.4

getBorder

public static Border getBorder(Object key)
Returns a border from the defaults table.

getBorder

public static Border getBorder(Object key,
                               Locale locale)
Returns a border from the defaults table.
Since:
1.4

getColor

public static Color getColor(Object key)
Returns a drawing color from the defaults table.

getColor

public static Color getColor(Object key,
                             Locale locale)
Returns a drawing color from the defaults table.

getCrossPlatformLookAndFeelClassName

public static String getCrossPlatformLookAndFeelClassName()
The fully qualified class name of the cross platform (Metal) look and feel. This string can be passed to Class.forName()
Returns:
"javax.swing.plaf.metal.MetalLookAndFeel"

getDefaults

public static UIDefaults getDefaults()
Returns the default values for this look and feel.
Returns:
The UIDefaults for the current LookAndFeel.

getDimension

public static Dimension getDimension(Object key)
Returns a dimension from the defaults table.

getDimension

public static Dimension getDimension(Object key,
                                     Locale locale)
Returns a dimension from the defaults table.

getFont

public static Font getFont(Object key)
Retrieves a font from the defaults table of the current LookAndFeel.
Parameters:
key - an Object that specifies the font. Typically, this is a String such as TitledBorder.font.

getFont

public static Font getFont(Object key,
                           Locale locale)
Retrieves a font from the defaults table of the current LookAndFeel.
Parameters:
key - an Object that specifies the font. Typically, this is a String such as TitledBorder.font.

getIcon

public static Icon getIcon(Object key)
Returns an Icon from the defaults table.

getIcon

public static Icon getIcon(Object key,
                           Locale locale)
Returns an Icon from the defaults table.

getInsets

public static Insets getInsets(Object key)
Returns an Insets object from the defaults table.

getInsets

public static Insets getInsets(Object key,
                               Locale locale)
Returns an Insets object from the defaults table.

getInstalledLookAndFeels

public static UIManager.LookAndFeelInfo[] getInstalledLookAndFeels()
Returns an array containing information about the LookAndFeels that are installed.
Returns:
A list of the look and feels that are available (installed).

getInt

public static int getInt(Object key)

getInt

public static int getInt(Object key,
                         Locale locale)

getLookAndFeel

public static LookAndFeel getLookAndFeel()
Returns the current look and feel (which may be null).
Returns:
The current look and feel.

getLookAndFeelDefaults

public static UIDefaults getLookAndFeelDefaults()
Returns the UIDefaults table of the currently active look and feel.
Returns:
The UIDefaults for the current LookAndFeel.

getPropertyChangeListeners

public static PropertyChangeListener[] getPropertyChangeListeners()
Returns an array of all added PropertyChangeListener objects.
Returns:
an array of listeners
Since:
1.4

getString

public static String getString(Object key)
Returns a string from the defaults table.

getString

public static String getString(Object key,
                               Locale locale)
Returns a string from the defaults table.

getSystemLookAndFeelClassName

public static String getSystemLookAndFeelClassName()
Returns the name of the LookAndFeel class that implements the native systems look and feel if there is one, otherwise the name of the default cross platform LookAndFeel class.
Returns:
The fully qualified class name for the system look and feel.

getUI

public static ComponentUI getUI(JComponent target)
Returns UI delegate from the current LookAndFeel that renders the target component.
Parameters:
target - the target component.

installLookAndFeel

public static void installLookAndFeel(String name,
                                      String className)
Creates a new look and feel and adds it to the current array.
Parameters:
name - the look and feel name.
className - the fully qualified name of the class that implements the look and feel.

installLookAndFeel

public static void installLookAndFeel(UIManager.LookAndFeelInfo info)
Adds the specified look and feel to the current array and then calls setInstalledLookAndFeels(javax.swing.UIManager.LookAndFeelInfo[]).

put

public static Object put(Object key,
                         Object value)
Stores an object in the defaults table.

removeAuxiliaryLookAndFeel

public static boolean removeAuxiliaryLookAndFeel(LookAndFeel laf)
Removes a LookAndFeel (LAF) from the list of auxiliary LAFs.
Parameters:
laf - the LAF to remove.
Returns:
true if the LAF was removed, and false otherwise.

removePropertyChangeListener

public static void removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list.
Parameters:
listener - the listener to remove

setInstalledLookAndFeels

public static void setInstalledLookAndFeels(UIManager.LookAndFeelInfo[] infos)
Replaces the current array of installed LookAndFeelInfos.

setLookAndFeel

public static void setLookAndFeel(String className)
            throws ClassNotFoundException,
                   InstantiationException,
                   IllegalAccessException,
                   UnsupportedLookAndFeelException
Set the current default look and feel using a class name.
Parameters:
className - the look and feel class name.
Throws:
UnsupportedLookAndFeelException - if the look and feel is not supported on the current platform.

setLookAndFeel

public static void setLookAndFeel(LookAndFeel newLookAndFeel)
            throws UnsupportedLookAndFeelException
Sets the current LookAndFeel.
Parameters:
newLookAndFeel - the new look and feel (null permitted).
Throws:
UnsupportedLookAndFeelException - if the look and feel is not supported on the current platform.

UIManager.java -- Copyright (C) 2002, 2003, 2004, 2005, 2006, Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath 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 for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.