Monday, 26 May 2008

Netbeans 6.0 and Mac OS X


(This post was originally written circa Dec. 2007)

Netbeans 6.0 is out, it looks really good, some of the code editor improvements are brilliant (actually I really like the color scheme : ) ). Thats besides the point, there is a major problem that I have with using Netbeans 6.0 on Mac OS X 10.5. The problem is that the menu-bar is just endless and as a result covers most of my stat-counters etc. So, how does one fix it, simple switch to the metal LAF. Some of us, me actually, like the blueish Java metal LAF. So to do this just run netbeans with a few command line parameters, like so,
/Applications/NetBeans/NetBeans\ 6.0.app/Contents/MacOS/netbeans --laf
javax.swing.plaf.metal.MetalLookAndFeel --fontsize 12

This, launches Netbeans 6.0 (provided you have chosen the default installation location) with the metal look and feel, and a font size of 12 (the default is 11). As can be seen in the screenshot, a new dock icon is launched however and I haven't figured out how to link the Netbeans.app one and the one that launches from the using the binary file.

In general, to use the Metal look and feel with your Java applications on Mac OS X, simply launch them with the following command line parameter
-Dswing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel

for example,
java -Dswing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel -jar
/Developer/Examples/Java/JFC/SwingSet2/SwingSet2.jar

launches the swing set example, with the metal look and feel. This of-course cannot be used with the /jdkhome/bin commands, jconsole for example. To change your default settings that is to have applications launch with the Metal LAF by default, you need to edit the swing.properties file.
17864397:~ anujseth$ cd /Library/Java/Home/lib
17864397:lib anujseth$ sudo vi swing.properties

The default is set to Apple's Aqua LAF and can be changed accordingly, for example,
#the java metal LAF
swing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel
#apple default setting
#swing.defaultlaf=apple.laf.AquaLookAndFeel

this is what my swing.properties file looks like.

Thats about it, I wrote this because I could not really find any such document on the Metal LAF, ah well maybe I'm the only crazy one who prefers it to all native-ish LAF's. Dare I say, Happy Hacking!, :).

8 comments:

  1. why did you not use the native look and feel?

    ReplyDelete
  2. i don’t quite get your question ? the point of the post is in case someone wants to get away from the default LAF, to each their own i guess.

    ReplyDelete
  3. Thx for the tip, personally i like the Metal LAF more than the Aqua LAF, which is filled with round corners and is space consuming. Nice job!

    ReplyDelete
  4. Hi, i would like to change the default LAF and i have a problem, i'm new to mac and actually i never use terminal, so now i can see where the default LAF is, but i just can't save what i do. Would you help me?

    ReplyDelete
  5. you need to open the file with superuser rights to make permanent changes, so to modify the swing.properties file you must in your administrator account (which by default is your user account) use something like - sudo vi swing.properties, or sudo nano swing.properties

    ReplyDelete
  6. Hello there, I would like to use metal look - but with menu on the top, like I'm used to in 90% of apps. Is it possible somehow? Thanks.

    ReplyDelete
  7. I don't think so, but I'm not sure. Try googling I guess, sorry can't be of much more help.

    ReplyDelete