Swing Looks ...Great (Part III Nimbus)

Nimbus comes already with JDK 1.6.

Nimbus doesn't have to be installed, it is shipped with JDK 1.6. You only have to activate it. There is a hacky (because of reflection) but robust way to activate that. This complex approach is needed, because Nimbus was introduced with JDK 1.6u10 and was not available before.

try {
    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
            UIManager.setLookAndFeel(info.getClassName());
            break;
        }
    }
} catch (UnsupportedLookAndFeelException e) {
    // handle exception
} catch (ClassNotFoundException e) {
    // handle exception
} catch (InstantiationException e) {
    // handle exception
} catch (IllegalAccessException e) {
    // handle exception
}

[Code Snippet from:http://download.oracle.com/javase/6/docs/technotes/guides/jweb/otherFeatures/nimbus_laf.html]
The command line option -Dswing.defaultlaf=com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel can be used as well.

With NetBeans you can create a Nimbus mock-up in minutes (actually seconds).

Comments:

Nimbus is a great look and feel. Something I recently blogged myself when switching from using the Metal look and feel with NetBeans to Nimbus. It's just a shame Oracle have decided to keep Metal as the default for Java 7.

Posted by Ben on November 30, 2010 at 04:13 PM CET #

Ugly.

Posted by bender on November 30, 2010 at 04:36 PM CET #

@Bender,

A very clear statement. Then I think you will like more the native and built-in "Metal" l&f,

thanks!,

adam

Posted by adam-bien.com on November 30, 2010 at 04:42 PM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
...the last 150 posts
...the last 10 comments
License