How to set the brushed metal look and feel in a Swing app

If you're writing Java Swing code to run on Mac OS X, it's very easy to set your application to use the Mac "brushed metal" look and feel. All you have to do is make this call very early in the lifecycle of your application:

System.setProperty("apple.awt.brushMetalLook", "true");

If you set this brushMetalLook property properly, your Swing application will use the Mac brushed metal look when it starts up.

Apple discusses the setting of this system property in this link. Specifically they include the following warning, which you really want to pay attention to:

WARNING: This property must be set before the heavyweight peer for the Window is created. Once addNotify() has been called on the component, causing creation of the heavyweight peer, changing this property has no effect.

That warning is why I say that you want to make this system call very early. In my Java applications I typically have a controller class that gets everything started, and I make this system call almost immediately.

Two images with different look and feel settings

Here are two images that show the effect of this setting. This first image shows what my application looks like without setting the Mac OS X brushed metal look and feel:

This second image shows what the same application looks like after I've set this brushMetalLook property:

As you can see, the look and feel is significantly different, and the difference is entirely due to this one property setting.