Ubuntu – way to specify a global look and feel for swing apps


Every time I install Netbeans on Ubuntu, I have to edit the ./etc/netbeans.conf file to include an option specifying the look and feel; otherwise, the menus are all black on dark gray, which is impossible to use.

Is there a way to specify a global look and feel for swing apps, so that this isn't such a pain? Here is the line I have to change:

46: netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.zip.disableMemoryMapping=true"


46: netbeans_default_options="--laf com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel -J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.zip.disableMemoryMapping=true"

Best Answer

The menus are dark and gray because of a Java bug. You can find it on Ubuntu's bug tracker. In the meantime, if you want to integrate Netbeans in the global menu, there's a way to do that. Here's how it looks like: http://www.youtube.com/watch?v=E8d9szgPhs8

The steps, obtained from this blog post are as follows.

  1. First install openjdk-7-jdk. It's required, so if you use 6, be careful.
  2. To make Netbeans use openjdk-7-jdk, launch Netbeans with

    /opt/netbeans-7.1.2/bin/netbeans --jdkhome /usr/lib/jvm/java-7-openjdk-i386

    You can make a .desktop file in ~/.local/share/applications with that as the exec command, for conveience. Copy the default one and edit it.

  3. Install and use the Java Swing Ayatana plugin from this googlecode page.
  4. Restart Netbeans.