By Ethan Nicholas
When the venerable Metal
look and feel for Swing first debuted, its main aesthetic
competition was the Windows
95 interface. Given the state of graphical user interfaces a decade
ago, Metal was an attractive and elegant alternative to the other common
interfaces of the time.
The updated Ocean
theme in Java SE 5 helped to keep Metal a viable choice up to the
present day, but it's time for Swing's cross-platform look and feel to get an
Enter the Nimbus Look and Feel. A
brand new, modern look and feel based on Synth, Nimbus provides a
polished look to applications which choose to use it. And because Nimbus is
drawn entirely using Java 2D vector graphics, rather than static bitmaps, it's
tiny (only 56KB!) and can be rendered at arbitrary resolutions.
For compatibility reasons, Metal is still the default Swing look and feel, but
updating applications to use Nimbus couldn't be simpler. It only takes a single
line of code:
You can also force Nimbus to be the default look and feel by specifying
on the command line. A more permanent way to set the property is to add
to the file
<JAVA_HOME>/lib/swing.properties. You will have to create
the swing.properties file if it does not already exist.
For further reading about Nimbus, take a look at the Nimbus early