UIManager (Java SE 15 & JDK 15) (original) (raw)
Method Details
getInstalledLookAndFeels
Returns an array of LookAndFeelInfo
s representing theLookAndFeel
implementations currently available. TheLookAndFeelInfo
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 LookAndFeel
objects, LookAndFeelInfo
maintains the class name of the LookAndFeel
class, not the actualLookAndFeel
instance.
The following example illustrates setting the current look and feel from an instance of LookAndFeelInfo
:
UIManager.setLookAndFeel(info.getClassName());
Returns:
an array of LookAndFeelInfo
objects
See Also:
setLookAndFeel(javax.swing.LookAndFeel)
setInstalledLookAndFeels
Sets the set of available look and feels. While this method does not check to ensure all of the LookAndFeelInfos
arenon-null
, it is strongly recommended that only non-null
values are supplied in the infos
array.
Parameters:infos
- set of LookAndFeelInfo
objects specifying the available look and feels
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if infos
is null
[SecurityException](../../../java.base/java/lang/SecurityException.html "class in java.lang")
See Also:
getInstalledLookAndFeels()
installLookAndFeel
Adds the specified look and feel to the set of available look and feels. While this method allows a null
info
, it is strongly recommended that a non-null
value be used.
Parameters:info
- a LookAndFeelInfo
object that names the look and feel and identifies the class that implements it
See Also:
setInstalledLookAndFeels(javax.swing.UIManager.LookAndFeelInfo[])
installLookAndFeel
public static void installLookAndFeel(String name,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 non-null
values be supplied.
Parameters:name
- descriptive name of the look and feelclassName
- name of the class that implements the look and feel
See Also:
setInstalledLookAndFeels(javax.swing.UIManager.LookAndFeelInfo[])
getLookAndFeel
Returns the current look and feel or null
.
Returns:
current look and feel, or null
See Also:
setLookAndFeel(javax.swing.LookAndFeel)
createLookAndFeel
Creates a supported built-in Java LookAndFeel
specified by the given L&F name
name.
Parameters:name
- a String
specifying the name of the built-in look and feel
Returns:
the built-in LookAndFeel
object
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if name
is null
[UnsupportedLookAndFeelException](UnsupportedLookAndFeelException.html "class in javax.swing")
- if the built-in Java L&F
is not found for the given name or it is not supported by the underlying platform
Since:
9
See Also:
LookAndFeel.getName(), LookAndFeel.isSupportedLookAndFeel()
setLookAndFeel
Sets the current look and feel to newLookAndFeel
. If the current look and feel is non-null
uninitialize
is invoked on it. If newLookAndFeel
isnon-null
, initialize
is invoked on it followed by getDefaults
. The defaults returned from newLookAndFeel.getDefaults()
replace those of the defaults from the previous look and feel. If the newLookAndFeel
isnull
, the look and feel defaults are set to null
.
A value of null
can be used to set the look and feel to null
. As the LookAndFeel
is required for most of Swing to function, setting the LookAndFeel
tonull
is strongly discouraged.
This is a JavaBeans bound property.
Parameters:newLookAndFeel
- LookAndFeel
to install
Throws:[UnsupportedLookAndFeelException](UnsupportedLookAndFeelException.html "class in javax.swing")
- ifnewLookAndFeel
is non-null
andnewLookAndFeel.isSupportedLookAndFeel()
returnsfalse
See Also:
getLookAndFeel()
setLookAndFeel
Loads the LookAndFeel
specified by the given class name, using the current thread's context class loader, and passes it to setLookAndFeel(LookAndFeel)
.
Parameters:className
- a string specifying the name of the class that implements the look and feel
Throws:[ClassNotFoundException](../../../java.base/java/lang/ClassNotFoundException.html "class in java.lang")
- if the LookAndFeel
class could not be found[InstantiationException](../../../java.base/java/lang/InstantiationException.html "class in java.lang")
- if a new instance of the class couldn't be created[IllegalAccessException](../../../java.base/java/lang/IllegalAccessException.html "class in java.lang")
- if the class or initializer isn't accessible[UnsupportedLookAndFeelException](UnsupportedLookAndFeelException.html "class in javax.swing")
- iflnf.isSupportedLookAndFeel()
is false[ClassCastException](../../../java.base/java/lang/ClassCastException.html "class in java.lang")
- if className
does not identify a class that extends LookAndFeel
[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if className
is null
getSystemLookAndFeelClassName
public static String getSystemLookAndFeelClassName()
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 theswing.systemlaf
system property.
Returns:
the String
of the LookAndFeel
class
See Also:
setLookAndFeel(javax.swing.LookAndFeel), getCrossPlatformLookAndFeelClassName()
getCrossPlatformLookAndFeelClassName
public 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). This value can be overriden by setting theswing.crossplatformlaf
system property.
Returns:
a string with the JLF implementation-class
See Also:
setLookAndFeel(javax.swing.LookAndFeel), getSystemLookAndFeelClassName()
getDefaults
Returns the defaults. The returned defaults resolve using the logic specified in the class documentation.
Returns:
a UIDefaults
object containing the default values
getFont
Returns a font from the defaults. If the value for key
is not a Font
, null
is returned.
Parameters:key
- an Object
specifying the font
Returns:
the Font
object
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key
is null
getFont
Returns a font from the defaults that is appropriate for the given locale. If the value for key
is not a Font
, null
is returned.
Parameters:key
- an Object
specifying the fontl
- the Locale
for which the font is desired; refer to UIDefaults
for details on how a null
Locale
is handled
Returns:
the Font
object
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key
is null
Since:
1.4
getColor
Returns a color from the defaults. If the value for key
is not a Color
, null
is returned.
Parameters:key
- an Object
specifying the color
Returns:
the Color
object
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key
is null
getColor
Returns a color from the defaults that is appropriate for the given locale. If the value for key
is not a Color
, null
is returned.
Parameters:key
- an Object
specifying the colorl
- the Locale
for which the color is desired; refer to UIDefaults
for details on how a null
Locale
is handled
Returns:
the Color
object
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key
is null
Since:
1.4
getIcon
Returns an Icon
from the defaults. If the value forkey
is not an Icon
, null
is returned.
Parameters:key
- an Object
specifying the icon
Returns:
the Icon
object
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key
is null
getIcon
Returns an Icon
from the defaults that is appropriate for the given locale. If the value forkey
is not an Icon
, null
is returned.
Parameters:key
- an Object
specifying the iconl
- the Locale
for which the icon is desired; refer to UIDefaults
for details on how a null
Locale
is handled
Returns:
the Icon
object
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key
is null
Since:
1.4
getBorder
Returns a border from the defaults. If the value forkey
is not a Border
, null
is returned.
Parameters:key
- an Object
specifying the border
Returns:
the Border
object
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key
is null
getBorder
Returns a border from the defaults that is appropriate for the given locale. If the value forkey
is not a Border
, null
is returned.
Parameters:key
- an Object
specifying the borderl
- the Locale
for which the border is desired; refer to UIDefaults
for details on how a null
Locale
is handled
Returns:
the Border
object
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key
is null
Since:
1.4
getString
Returns a string from the defaults. If the value forkey
is not a String
, null
is returned.
Parameters:key
- an Object
specifying the string
Returns:
the String
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key
is null
getString
Returns a string from the defaults that is appropriate for the given locale. If the value forkey
is not a String
, null
is returned.
Parameters:key
- an Object
specifying the stringl
- the Locale
for which the string is desired; refer to UIDefaults
for details on how a null
Locale
is handled
Returns:
the String
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key
is null
Since:
1.4
getInt
public static int getInt(Object key)
Returns an integer from the defaults. If the value forkey
is not an Integer
, or does not exist,0
is returned.
Parameters:key
- an Object
specifying the int
Returns:
the int
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key
is null
getInt
Returns an integer from the defaults that is appropriate for the given locale. If the value forkey
is not an Integer
, or does not exist,0
is returned.
Parameters:key
- an Object
specifying the intl
- the Locale
for which the int is desired; refer to UIDefaults
for details on how a null
Locale
is handled
Returns:
the int
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key
is null
Since:
1.4
getBoolean
public static boolean getBoolean(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 false
is returned.
Parameters:key
- an Object
specifying the key for the desired boolean value
Returns:
the boolean value corresponding to the key
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key
is null
Since:
1.4
getBoolean
public static boolean getBoolean(Object key,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 false
will be returned.
Parameters:key
- an Object
specifying the key for the desired boolean valuel
- the Locale
for which the boolean is desired; refer to UIDefaults
for details on how a null
Locale
is handled
Returns:
the boolean value corresponding to the key
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key
is null
Since:
1.4
getInsets
Returns an Insets
object from the defaults. If the value for key
is not an Insets
, null
is returned.
Parameters:key
- an Object
specifying the Insets
object
Returns:
the Insets
object
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key
is null
getInsets
Returns an Insets
object from the defaults that is appropriate for the given locale. If the value for key
is not an Insets
, null
is returned.
Parameters:key
- an Object
specifying the Insets
objectl
- the Locale
for which the object is desired; refer to UIDefaults
for details on how a null
Locale
is handled
Returns:
the Insets
object
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key
is null
Since:
1.4
getDimension
Returns a dimension from the defaults. If the value for key
is not a Dimension
, null
is returned.
Parameters:key
- an Object
specifying the dimension object
Returns:
the Dimension
object
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key
is null
getDimension
Returns a dimension from the defaults that is appropriate for the given locale. If the value for key
is not a Dimension
, null
is returned.
Parameters:key
- an Object
specifying the dimension objectl
- the Locale
for which the object is desired; refer to UIDefaults
for details on how a null
Locale
is handled
Returns:
the Dimension
object
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key
is null
Since:
1.4
get
Returns an object from the defaults.
Parameters:key
- an Object
specifying the desired object
Returns:
the Object
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key
is null
get
Returns an object from the defaults that is appropriate for the given locale.
Parameters:key
- an Object
specifying the desired objectl
- the Locale
for which the object is desired; refer to UIDefaults
for details on how a null
Locale
is handled
Returns:
the Object
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key
is null
Since:
1.4
put
Stores an object in the developer defaults. This is a cover method for getDefaults().put(key, value)
. This only effects the developer defaults, not the system or look and feel defaults.
Parameters:key
- an Object
specifying the retrieval keyvalue
- the Object
to store; refer toUIDefaults
for details on how null
is handled
Returns:
the Object
returned by UIDefaults.put(java.lang.Object, java.lang.Object)
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if key
is null
See Also:
UIDefaults.put(java.lang.Object, java.lang.Object)
getUI
Returns the appropriate ComponentUI
implementation fortarget
. Typically, this is a cover forgetDefaults().getUI(target)
. However, if an auxiliary look and feel has been installed, this first invokesgetUI(target)
on the multiplexing look and feel's defaults, and returns that value if it is non-null
.
Parameters:target
- the JComponent
to return theComponentUI
for
Returns:
the ComponentUI
object for target
Throws:[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if target
is null
See Also:
UIDefaults.getUI(javax.swing.JComponent)
getLookAndFeelDefaults
public static UIDefaults getLookAndFeelDefaults()
Returns the 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 UIDefaults
returned fromgetDefaults()
. As the current look and feel may expect certain values to exist, altering the UIDefaults
returned from this method could have unexpected results.
Returns:UIDefaults
from the current look and feel
See Also:
getDefaults(), setLookAndFeel(LookAndFeel), LookAndFeel.getDefaults()
addAuxiliaryLookAndFeel
public static void addAuxiliaryLookAndFeel(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.
Parameters:laf
- the LookAndFeel
object
See Also:
removeAuxiliaryLookAndFeel(javax.swing.LookAndFeel), setLookAndFeel(javax.swing.LookAndFeel), getAuxiliaryLookAndFeels(), getInstalledLookAndFeels()
removeAuxiliaryLookAndFeel
public static boolean removeAuxiliaryLookAndFeel(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.
Parameters:laf
- the LookAndFeel
to be removed
Returns:
true if the LookAndFeel
was removed from the list
See Also:
removeAuxiliaryLookAndFeel(javax.swing.LookAndFeel), getAuxiliaryLookAndFeels(), setLookAndFeel(javax.swing.LookAndFeel), getInstalledLookAndFeels()
getAuxiliaryLookAndFeels
public static 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.
Returns:
list of auxiliary LookAndFeel
s or null
See Also:
addAuxiliaryLookAndFeel(javax.swing.LookAndFeel), removeAuxiliaryLookAndFeel(javax.swing.LookAndFeel), setLookAndFeel(javax.swing.LookAndFeel), getInstalledLookAndFeels()
addPropertyChangeListener
Adds a PropertyChangeListener
to the listener list. The listener is registered for all properties.
Parameters:listener
- the PropertyChangeListener
to be added
See Also:
PropertyChangeSupport
removePropertyChangeListener
Removes a PropertyChangeListener
from the listener list. This removes a PropertyChangeListener
that was registered for all properties.
Parameters:listener
- the PropertyChangeListener
to be removed
See Also:
PropertyChangeSupport
getPropertyChangeListeners
Returns an array of all the PropertyChangeListener
s added to this UIManager with addPropertyChangeListener().
Returns:
all of the PropertyChangeListener
s added or an empty array if no listeners have been added
Since:
1.4