Java Reference
In-Depth Information
Table 20-10. MetalTheme Properties (Continued)
Property Name
Data Type
Access
userTextFont
FontUIResource
Read-only
white
ColorUIResource
Read-only
windowBackground
ColorUIResource
Read-only
windowTextFont
FontUIResource
Read-only
windowTitleBackground
ColorUIResource
Read-only
windowTitleForeground
ColorUIResource
Read-only
windowTitleInactiveBackground
ColorUIResource
Read-only
windowTitleInactiveForeground
ColorUIResource
Read-only
DefaultMetalTheme and OceanTheme Classes
Contrary to the class name, the DefaultMetalTheme class is not the default Metal theme; the
default is OceanTheme . DefaultMetalTheme calls itself the Steel theme and uses a blue and gray
color scheme for the primary and secondary settings, respectively. OceanTheme , named Ocean,
uses a light-blue palette with frequent gradient fills for backgrounds.
To use the Steel theme instead of the Ocean theme, you need to set the swing.metalTheme
system property to steel , as shown here:
java -Dswing.metalTheme=steel ClassName
Most people prefer the newer look of Ocean, but Steel is still available for backward-
compatibility, as Ocean is new to 5.0.
If you create your own Metal theme, you need to subclass either OceanTheme or
DefaultMetalTheme , and then install the custom theme by setting the static currentTheme
property of the MetalLookAndFeel class to your theme.
MetalTheme myTheme = new MyTheme();
MetalLookAndFeel.setCurrentTheme(myTheme);
Whereas most of the customizations of a MetalTheme are related to fonts and colors, the
public void addCustomEntriesToTable(UIDefaults table) method allows you to override the
default UIDefaults settings for the Metal look and feel. Therefore, not only do themes customize
the fonts and colors of the Swing components, but they also can customize any one of the
many UIResource -related properties of the Swing components.
The following code demonstrates how to set two of the scrollbar settings for a specific
theme. Remember to tag these settings with the UIResource interface when appropriate, and
don't forget to initialize the table argument by your superclass implementation (eventually,
this would be MetalTheme ).
Search WWH ::




Custom Search