Over a million developers have joined DZone.
Silver Partner

Swing Looks ...Great (Part III Nimbus)

· Java Zone

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).

From http://www.adam-bien.com/roller/abien/entry/swing_looks_great_part_iii

Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}