Java Reference
In-Depth Information
Figure 8-37. An example of using the Metal look and feel with the Steel theme
With JDK 5, Sun has modified this look and feel, as shown in Figure 8-38.
Figure 8-38. An example of using the Metal look and feel with the Ocean theme
To help reduce confusion, Sun has named these two versions of the same look and feel
“Steel” and “Ocean,” respectively.
If you wish to use the old theme, you can set the following system property:
-Dswing.metalTheme=steel
Skins Look and Feel
A “skin” (also called a “theme”) is a way of changing the look and feel of an application or web-
site, without changing any code. This is usually achieved by modifying a configuration file.
Sun has created javax.swing.plaf.synth.SynthLookAndFeel as a skinnable look and feel,
allowing the look and feel to be specified in a file. This means that your users could modify
this file to make your application meet their preferred look and feel without needing any
coding changes.
Adding Components to Swing Containers Has Been Simplified
Prior to JDK 5, it was not possible to directly add components to any class that implemented
RootPaneContainer , namely JApplet , JDialog , JFrame , JInternalFrame , and JWindow . Instead,
you had to get the content pane, then add the components to it. This resulted in code that
looks like this:
JFrame theFrame = new JFrame();
theFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container thePane = theFrame.getContentPane();
thePane.add(new JButton("Exit"));
theFrame.pack();
theFrame.setVisible(true);
Search WWH ::




Custom Search