Java Reference
In-Depth Information
APPENDIX
■ ■ ■
UI Manager Properties
T hroughout this topic are tables that list the property names and data types for all the UIResource
elements of specific Swing components. Although these tables show all the information about
a specific component, it is handy to have the information about property names for all of the
components in one place.
With that in mind, this appendix provides a complete, alphabetical list of properties used
by the predefined look and feel classes—Motif, Metal/Ocean, Windows, GTK, and Synth—
provided with the Swing release for the Java 2 Platform Standard Edition, version 5.0 (J2SE 5.0).
The table indicates with an X which of the five look and feel classes uses a particular property.
For properties defined within the base Basic look and feel, these are assumed to be used by
all the look and feel types, since all of the system-defined look and feel classes extend from
BasicLookAndFeel . It is possible that a subclass masks the use of a property defined for the Basic
look and feel, and in fact doesn't physically use one flagged as such in the table. Also, since the
GTK look and feel is a subclass of Synth, a similar situation arises with GTK, too.
To change the default setting for any of these properties, you need to notify the UIManager
by storing a new setting in the lookup table of the UIManager . For instance, to change the default
text for the Yes button in a JOptionPane , you need to replace the OptionPane.yesButtonText property
with the new setting ( Si , in this example):
UIManager.put("OptionPane.yesButtonText", "Si");
Then any component created after the setting change will get the new value: Si . If you
want a displayed component to get the new setting, you must call its updateUI() method after
changing the setting.
When you change the current look and feel, any custom settings you install may be lost. If
the class of the property value setting implements the UIResource interface (an empty marker
interface such as Serializable ), the setting will be replaced by the default setting of the look
and feel. For example, the following setting would be saved when the look and feel changes:
UIManager.put("OptionPane.background", Color.RED);
Conversely, the following setting would not be saved when the look and feel changes:
UIManager.put("OptionPane.background", new ColorUIResource(Color.RED));
If the property value setting does not implement the UIResource interface, the property
setting is retained when the look and feel changes.
813
Search WWH ::




Custom Search