Java Reference
In-Depth Information
public void addCustomEntriesToTable(UIDefaults table) {
super.addCustomEntriesToTable(table);
ColorUIResource thumbColor = new ColorUIResource(Color.MAGENTA);
table.put("Scrollbar.thumb", thumbColor);
table.put("ScrollBar.width", new Integer(25));
}
The Metalworks system demo provided with the JDK installation ( jdk1.5.0\demo\
jfc\Metalworks ) comes with examples for customizing themes. One of the themes it defines
reads the theme color settings from a property file. Instead of needing to create a new class file
every time you want to change the theme of your Swing application, you can read it from a file
at runtime.
name=Charcoal
primary1=33,66,66
primary2=66,99,99
primary3=99,99,99
secondary1=0,0,0
secondary2=51,51,51
secondary3=102,102,102
black=255,255,255
white=0,0,0
Figure 20-8 shows the Charcoal theme just described used within the Metalworks demon-
stration program. Figure 20-9 shows the Presentation theme it defines.
Figure 20-8. Charcoal theme within the Metalworks demonstration program
Search WWH ::




Custom Search