20080707

Brushed Metal Toolbars in Java

I've been working on a Swing application under OS X. I recently became a bit frustrated with the ugly, Java-style toolbars that it was using. They fit in well for Windows, but not on the Mac. So, I did a bit of searching and found the following two links for making Java applications pretty under OS X, one for Control Styles, and another for General Integration Issues.

I couldn't find any built-in solution for creating OS X Brushed Metal toolbars (like the ones in Mail, Pages, etc). However, with some layout help I was able to create a similar effect by using two buttons; one for the icon (segmentedCapsule) and the other for the text (segmentedCapsule with a null border). This is the result:


Not too bad for a Swing application, eh?

The only down side is that this is not a "proper" way to create this effect. In addition, the button text doesn't have a correct drop-shadow, and the interaction between the text and the button when you click it is not quite the same as OS X. However, it's much better than the default Java toolbar.

As a side note, I should mention that although this application uses Swing, it is written entirely in Scala.