javax.swing
public class UIManager extends Object implements Serializable
LookAndFeel
and any auxiliary LookAndFeel
instances.Modifier and Type | Class and Description |
---|---|
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 and Description |
---|
UIManager()
Creates a new instance of the
UIManager . |
Modifier and Type | Method and Description |
---|---|
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
LookAndFeel s that are in use. |
static boolean |
getBoolean(Object key)
Returns a boolean value from the defaults table.
|
static boolean |
getBoolean(Object key,
Locale locale)
Returns a boolean value from the defaults table.
|
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
LookAndFeel s
that are installed. |
static int |
getInt(Object key)
Returns the integer value of the
Integer associated with the
given key. |
static int |
getInt(Object key,
Locale locale)
Returns the integer value of the
Integer associated with the
given key. |
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 the
String associated with the given key. |
static String |
getString(Object key,
Locale locale)
Returns the
String associated with the given key. |
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(LookAndFeel newLookAndFeel)
Sets the current
LookAndFeel . |
static void |
setLookAndFeel(String className)
Set the current default look and feel using a class name.
|
public UIManager()
UIManager
. There is no need
to construct an instance of this class, since all methods are static.public static void addPropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener
to the listener list.listener
- the listener to addpublic static void removePropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener
from the listener list.listener
- the listener to removepublic static PropertyChangeListener[] getPropertyChangeListeners()
PropertyChangeListener
objects.public static void addAuxiliaryLookAndFeel(LookAndFeel laf)
LookAndFeel
to the list of auxiliary look and feels.laf
- the auxiliary look and feel (null
not permitted).NullPointerException
- if laf
is null
.getAuxiliaryLookAndFeels()
public static boolean removeAuxiliaryLookAndFeel(LookAndFeel laf)
LookAndFeel
(LAF) from the list of auxiliary LAFs.laf
- the LAF to remove.true
if the LAF was removed, and false
otherwise.public static LookAndFeel[] getAuxiliaryLookAndFeels()
null
) containing the auxiliary
LookAndFeel
s that are in use. These are used by the
MultiLookAndFeel
class.null
).addAuxiliaryLookAndFeel(LookAndFeel)
public static Object get(Object key)
UIDefaults
table for the current
LookAndFeel
.key
- the key.public static Object get(Object key, Locale locale)
UIDefaults
table for the current
LookAndFeel
.key
- the key.public static boolean getBoolean(Object key)
Boolean
,
this method returns false
.key
- the key (null
not permitted).NullPointerException
- if key
is null
.public static boolean getBoolean(Object key, Locale locale)
Boolean
,
this method returns false
.key
- the key (null
not permitted).locale
- the locale.NullPointerException
- if key
is null
.public static Border getBorder(Object key)
key
- the key (null
not permitted).null
.NullPointerException
- if key
is null
.public static Border getBorder(Object key, Locale locale)
key
- the key (null
not permitted).locale
- the locale.null
.NullPointerException
- if key
is null
.public static Color getColor(Object key)
key
- the key (null
not permitted).null
.NullPointerException
- if key
is null
.public static Color getColor(Object key, Locale locale)
key
- the key (null
not permitted).locale
- the locale.null
.NullPointerException
- if key
is null
.public static String getCrossPlatformLookAndFeelClassName()
"javax.swing.plaf.metal.MetalLookAndFeel"
public static UIDefaults getDefaults()
UIDefaults
for the current LookAndFeel
.public static Dimension getDimension(Object key)
key
- the key (null
not permitted).null
.NullPointerException
- if key
is null
.public static Dimension getDimension(Object key, Locale locale)
key
- the key (null
not permitted).locale
- the locale.null
.NullPointerException
- if key
is null
.public static Font getFont(Object key)
key
- an Object that specifies the font. Typically,
this is a String such as
TitledBorder.font
.null
.NullPointerException
- if key
is null
.public static Font getFont(Object key, Locale locale)
key
- an Object that specifies the font. Typically,
this is a String such as
TitledBorder.font
.locale
- the locale.null
.NullPointerException
- if key
is null
.public static Icon getIcon(Object key)
key
- the key (null
not permitted).null
.NullPointerException
- if key
is null
.public static Icon getIcon(Object key, Locale locale)
key
- the key (null
not permitted).locale
- the locale.null
.NullPointerException
- if key
is null
.public static Insets getInsets(Object key)
key
- the key (null
not permitted).null
.NullPointerException
- if key
is null
.public static Insets getInsets(Object key, Locale locale)
key
- the key (null
not permitted).locale
- the locale.null
.NullPointerException
- if key
is null
.public static UIManager.LookAndFeelInfo[] getInstalledLookAndFeels()
LookAndFeel
s
that are installed.public static int getInt(Object key)
Integer
associated with the
given key. If there is no value, or the value is not an instance of
Integer
, this method returns 0.key
- the key (null
not permitted).public static int getInt(Object key, Locale locale)
Integer
associated with the
given key. If there is no value, or the value is not an instance of
Integer
, this method returns 0.key
- the key (null
not permitted).locale
- the locale.public static LookAndFeel getLookAndFeel()
null
).setLookAndFeel(LookAndFeel)
public static UIDefaults getLookAndFeelDefaults()
UIDefaults
table of the currently active
look and feel.UIDefaults
for the current LookAndFeel
.public static String getString(Object key)
String
associated with the given key. If the value
is not a String
, this method returns null
.key
- the key (null
not permitted).null
.public static String getString(Object key, Locale locale)
String
associated with the given key. If the value
is not a String
, this method returns null
.key
- the key (null
not permitted).locale
- the locale.null
.public static String getSystemLookAndFeelClassName()
LookAndFeel
class that implements the
native systems look and feel if there is one, otherwise the name
of the default cross platform LookAndFeel class.getCrossPlatformLookAndFeelClassName()
public static ComponentUI getUI(JComponent target)
LookAndFeel
that renders the
target component.target
- the target component.public static void installLookAndFeel(String name, String className)
name
- the look and feel name.className
- the fully qualified name of the class that implements the
look and feel.public static void installLookAndFeel(UIManager.LookAndFeelInfo info)
public static Object put(Object key, Object value)
key
- the key.value
- the value.public static void setInstalledLookAndFeels(UIManager.LookAndFeelInfo[] infos)
public static void setLookAndFeel(LookAndFeel newLookAndFeel) throws UnsupportedLookAndFeelException
LookAndFeel
.newLookAndFeel
- the new look and feel (null
permitted).UnsupportedLookAndFeelException
- if the look and feel is not
supported on the current platform.LookAndFeel.isSupportedLookAndFeel()
public static void setLookAndFeel(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException
className
- the look and feel class name.UnsupportedLookAndFeelException
- if the look and feel is not
supported on the current platform.ClassNotFoundException
InstantiationException
IllegalAccessException
LookAndFeel.isSupportedLookAndFeel()