Mac specific properties for Swing applications

I think I've mentioned parts of this in other blog entries, but as I was just digging through a Java Swing application that I wrote specifically for the Mac OS X platform, I ran across the following source code, which sets up all of my system properties for the Mac environment:

  // set the brushed metal look and feel, if desired
  System.setProperty("apple.awt.brushMetalLook", "true");
  // use the mac system menu bar
  System.setProperty("apple.laf.useScreenMenuBar", "true");
  // set the "About" menu item name
  System.setProperty("", "WikiStar");
  // use smoother fonts
  System.setProperty("apple.awt.textantialiasing", "true");

  // ref:
  // use the system look and feel
catch (Exception e)
  // put your debug code here ...

You can find a discussion of several of these property settings on this Apple technical note.

Make these calls early

It's important to note that I make all of these calls almost immediately in the main controller of my Java/Swing application, because most of them (possibly all of them, I can't remember for sure) have to be set before you start creating any Swing components. I've found that these simple settings go a long way towards making my application look and feel more like a native Mac application.