|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.UIManager
public class UIManager
This class keeps track of the current look and feel and its defaults. The default look and feel class is chosen in the following manner:
swing.defaultlaf
is
non-null, use it as the default look and feel class name.
Properties
file swing.properties
exists and contains the key swing.defaultlaf
,
use its value as default look and feel class name. The location of
swing.properties
may vary depending upon the
implementation of the Java platform. In Sun's implementation
this will reside in
&java.home>/lib/swing.properties
. Refer to
the release notes of the implementation you are using for
further details.
We manage three levels of defaults: user defaults, look
and feel defaults, system defaults. A call to UIManager.get
checks all three levels in order and returns the first non-null
value for a key, if any. A call to UIManager.put
just
affects the user defaults. Note that a call to
setLookAndFeel
doesn't affect the user defaults, it just
replaces the middle defaults "level".
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 XMLEncoder
.
javax.swing.plaf.metal
Nested Class Summary | |
---|---|
static class |
UIManager.LookAndFeelInfo
Provides a little information about an installed LookAndFeel for the sake of configuring a menu or
for initial application set up. |
Constructor Summary | |
---|---|
UIManager()
|
Method Summary | |
---|---|
static void |
addAuxiliaryLookAndFeel(LookAndFeel laf)
Adds a LookAndFeel to the list of auxiliary look and feels. |
static void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. |
static Object |
get(Object key)
Returns an object from the defaults table. |
static Object |
get(Object key,
Locale l)
Returns an object from the defaults table that is appropriate for the given locale. |
static LookAndFeel[] |
getAuxiliaryLookAndFeels()
Returns the list of auxiliary look and feels (can be null ). |
static boolean |
getBoolean(Object key)
Returns a boolean from the defaults table which is associated with the key value. |
static boolean |
getBoolean(Object key,
Locale l)
Returns a boolean from the defaults table which is associated with the key value and the given Locale . |
static Border |
getBorder(Object key)
Returns a border from the defaults table. |
static Border |
getBorder(Object key,
Locale l)
Returns a border from the defaults table that is appropriate for the given locale. |
static Color |
getColor(Object key)
Returns a drawing color from the defaults table. |
static Color |
getColor(Object key,
Locale l)
Returns a drawing color from the defaults table that is appropriate for the given locale. |
static String |
getCrossPlatformLookAndFeelClassName()
Returns the name of the LookAndFeel class that implements
the default cross platform look and feel -- the Java
Look and Feel (JLF). |
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 l)
Returns a dimension from the defaults table that is appropriate for the given locale. |
static Font |
getFont(Object key)
Returns a drawing font from the defaults table. |
static Font |
getFont(Object key,
Locale l)
Returns a drawing font from the defaults table that is appropriate for the given locale. |
static Icon |
getIcon(Object key)
Returns an Icon from the defaults table. |
static Icon |
getIcon(Object key,
Locale l)
Returns an Icon from the defaults table that is appropriate
for the given locale. |
static Insets |
getInsets(Object key)
Returns an Insets object from the defaults table. |
static Insets |
getInsets(Object key,
Locale l)
Returns an Insets object from the defaults table that is
appropriate for the given locale. |
static UIManager.LookAndFeelInfo[] |
getInstalledLookAndFeels()
Returns an array of objects that provide some information about the LookAndFeel implementations that have been installed with this
software development kit. |
static int |
getInt(Object key)
Returns an integer from the defaults table. |
static int |
getInt(Object key,
Locale l)
Returns an integer from the defaults table that is appropriate for the given locale. |
static LookAndFeel |
getLookAndFeel()
Returns the current default look and feel or null . |
static UIDefaults |
getLookAndFeelDefaults()
Returns the default values for this look and feel. |
static PropertyChangeListener[] |
getPropertyChangeListeners()
Returns an array of all the PropertyChangeListener s added
to this UIManager with addPropertyChangeListener(). |
static String |
getString(Object key)
Returns a string from the defaults table. |
static String |
getString(Object key,
Locale l)
Returns a string from the defaults table that is appropriate for the given locale. |
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 the L&F object 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 from the list of auxiliary look and feels. |
static void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes 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 default look and feel using a LookAndFeel object. |
static void |
setLookAndFeel(String className)
Sets the current default look and feel using a class name. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UIManager()
Method Detail |
---|
public static UIManager.LookAndFeelInfo[] getInstalledLookAndFeels()
LookAndFeel
implementations that have been installed with this
software development kit. The LookAndFeel
info objects can
used by an application to construct a menu of look and feel options for
the user or to set the look and feel at start up time. Note that
we do not return the LookAndFeel
classes themselves here to
avoid the cost of unnecessarily loading them.
Given a LookAndFeelInfo
object one can set the current
look and feel like this:
UIManager.setLookAndFeel(info.getClassName());
LookAndFeelInfo
objectssetLookAndFeel(javax.swing.LookAndFeel)
public static void setInstalledLookAndFeels(UIManager.LookAndFeelInfo[] infos) throws SecurityException
LookAndFeelInfos
.
infos
- new array of LookAndFeelInfo
objects
SecurityException
getInstalledLookAndFeels()
public static void installLookAndFeel(UIManager.LookAndFeelInfo info)
setInstalledLookAndFeels(javax.swing.UIManager.LookAndFeelInfo[])
.
info
- a LookAndFeelInfo
object that names the
look and feel and identifies that class that implements itpublic static void installLookAndFeel(String name, String className)
setInstalledLookAndFeels(javax.swing.UIManager.LookAndFeelInfo[])
.
name
- a String
specifying the name of the
look and feelclassName
- a String
specifying the class name
that implements the look and feelpublic static LookAndFeel getLookAndFeel()
null
.
null
setLookAndFeel(javax.swing.LookAndFeel)
public static void setLookAndFeel(LookAndFeel newLookAndFeel) throws UnsupportedLookAndFeelException
LookAndFeel
object.
This is a JavaBeans bound property.
newLookAndFeel
- the LookAndFeel
object
UnsupportedLookAndFeelException
- if
lnf.isSupportedLookAndFeel()
is falsegetLookAndFeel()
public static void setLookAndFeel(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException
className
- a string specifying the name of the class that implements
the look and feel
ClassNotFoundException
- if the LookAndFeel
class could not be found
InstantiationException
- if a new instance of the class
couldn't be created
IllegalAccessException
- if the class or initializer isn't accessible
UnsupportedLookAndFeelException
- if
lnf.isSupportedLookAndFeel()
is falsepublic 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. If the system property swing.systemlaf
has been
defined, its value will be returned.
String
of the LookAndFeel
classsetLookAndFeel(javax.swing.LookAndFeel)
,
getCrossPlatformLookAndFeelClassName()
public static String getCrossPlatformLookAndFeelClassName()
LookAndFeel
class that implements
the default cross platform look and feel -- the Java
Look and Feel (JLF). If the system property
swing.crossplatformlaf
has been
defined, its value will be returned.
setLookAndFeel(javax.swing.LookAndFeel)
,
getSystemLookAndFeelClassName()
public static UIDefaults getDefaults()
UIDefaults
object containing the default valuespublic static Font getFont(Object key)
key
- an Object
specifying the font
Font
objectpublic static Font getFont(Object key, Locale l)
key
- an Object
specifying the fontl
- the Locale
for which the font is desired
Font
objectpublic static Color getColor(Object key)
key
- an Object
specifying the color
Color
objectpublic static Color getColor(Object key, Locale l)
key
- an Object
specifying the colorl
- the Locale
for which the color is desired
Color
objectpublic static Icon getIcon(Object key)
Icon
from the defaults table.
key
- an Object
specifying the icon
Icon
objectpublic static Icon getIcon(Object key, Locale l)
Icon
from the defaults table that is appropriate
for the given locale.
key
- an Object
specifying the iconl
- the Locale
for which the icon is desired
Icon
objectpublic static Border getBorder(Object key)
key
- an Object
specifying the border
Border
objectpublic static Border getBorder(Object key, Locale l)
key
- an Object
specifying the borderl
- the Locale
for which the border is desired
Border
objectpublic static String getString(Object key)
key
- an Object
specifying the string
String
public static String getString(Object key, Locale l)
key
- an Object
specifying the stringl
- the Locale
for which the string is desired
String
public static int getInt(Object key)
key
- an Object
specifying the int
public static int getInt(Object key, Locale l)
key
- an Object
specifying the intl
- the Locale
for which the int is desired
public static boolean getBoolean(Object key)
key
- an Object
specifying the key for the desired boolean value
public static boolean getBoolean(Object key, Locale l)
Locale
. If the key is not
found or the key doesn't represent
a boolean value then false will be returned.
key
- an Object
specifying the key for the desired
boolean valuel
- the Locale
for which the boolean is desired
public static Insets getInsets(Object key)
Insets
object from the defaults table.
key
- an Object
specifying the Insets
object
Insets
objectpublic static Insets getInsets(Object key, Locale l)
Insets
object from the defaults table that is
appropriate for the given locale.
key
- an Object
specifying the Insets
objectl
- the Locale
for which the object is desired
Insets
objectpublic static Dimension getDimension(Object key)
key
- an Object
specifying the dimension object
Dimension
objectpublic static Dimension getDimension(Object key, Locale l)
key
- an Object
specifying the dimension objectl
- the Locale
for which the object is desired
Dimension
objectpublic static Object get(Object key)
key
- an Object
specifying the desired object
Object
public static Object get(Object key, Locale l)
key
- an Object
specifying the desired objectl
- the Locale
for which the object is desired
Object
public static Object put(Object key, Object value)
key
- an Object
specifying the retrieval keyvalue
- the Object
to store
Object
returned by UIDefaults.put(java.lang.Object, java.lang.Object)
public static ComponentUI getUI(JComponent target)
target
- the JComponent
to render
ComponentUI
object that renders the target componentpublic static UIDefaults getLookAndFeelDefaults()
UIDefaults
object containing the default valuespublic static void addAuxiliaryLookAndFeel(LookAndFeel laf)
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.
laf
- the LookAndFeel
objectremoveAuxiliaryLookAndFeel(javax.swing.LookAndFeel)
,
setLookAndFeel(javax.swing.LookAndFeel)
,
getAuxiliaryLookAndFeels()
,
getInstalledLookAndFeels()
public static boolean removeAuxiliaryLookAndFeel(LookAndFeel laf)
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.
LookAndFeel
was removed from the listremoveAuxiliaryLookAndFeel(javax.swing.LookAndFeel)
,
getAuxiliaryLookAndFeels()
,
setLookAndFeel(javax.swing.LookAndFeel)
,
getInstalledLookAndFeels()
public static LookAndFeel[] getAuxiliaryLookAndFeels()
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.
LookAndFeel
s or null
addAuxiliaryLookAndFeel(javax.swing.LookAndFeel)
,
removeAuxiliaryLookAndFeel(javax.swing.LookAndFeel)
,
setLookAndFeel(javax.swing.LookAndFeel)
,
getInstalledLookAndFeels()
public static void addPropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener
to the listener list.
The listener is registered for all properties.
listener
- the PropertyChangeListener
to be addedPropertyChangeSupport
public static void removePropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener
from the listener list.
This removes a PropertyChangeListener
that was registered
for all properties.
listener
- the PropertyChangeListener
to be removedPropertyChangeSupport
public static PropertyChangeListener[] getPropertyChangeListeners()
PropertyChangeListener
s added
to this UIManager with addPropertyChangeListener().
PropertyChangeListener
s added or an empty
array if no listeners have been added
|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.