
Nimbus has been out for a while now. It has some great features. But why isn't it being used more?
Nimbus is the name of a look-and-feel designed by Sun for the Java Desktop System. It provides a great alternative for the Windows look and feel. But it provides more than that. It has a collection of features that allow developers to customize the look and feel of their products. Nimbus provides the ability to put custom skins on your product to help brand your product.
This is how is does that. All painting for components is done with simple stateless implementations of the Painter interface. These painters are stored in the UIDefaults table so they can be replaced if you would like to change the look of components or can be used in your own components if you would like to create a custom table header for example that looks the same as the standard Nimbus one plus something extra. All colors, icons and fonts are derived off UIDefaults keys so the whole UI can be customized by changing values in the UIDefaults tabl
All of the colors, fonts, icons, borders and painters are exposed through the UIDefaults table which means they are available to your 3rd party components to help you skin them in a Nimbus style.
So why isn't it being used more often given the amount of time that it has been out? There are two main reasons.
The first reason is the default file browser. Basically it is short. What this means to the user is that they have to scroll over all the time to be able to find anything in a directory of folder that has more than a handful of items in it. This is a rather annoying feature that would discourage any developer familiar with usability. So many developers will put their application look and feel back to the good old favorites hat they are familiar with.
The second reason is that the text objects all have
the feature (or bug depending on point of view) that don't work as expected. The more troubling of these is the foreground, background, and highlighting behavior. Another reason for most developers to give up on Nimbus.At present the best way to deal with this is a work around. The work around is basically to use set the text back to the old style handling.
To check to see if Nimbus is present and enable Nimbus if it is and then set the text panes so that they have the expected behavior you can use the following:
(Note: This example includes the text object decleration but this is usually done somewhere else in the IDE GUI build e.g. Netbeans
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
try {
UIManager.setLookAndFeel(info.getClassName());
} catch (ClassNotFoundException ex) {
// your exception handling
} catch (InstantiationException ex) {
// your exception handling
} catch (IllegalAccessException ex) {
// your exception handling
} catch (UnsupportedLookAndFeelException ex) {
// your exception handling
}
break;
}
}
// this is usually done somewhere else in the IDE GUI build e.g. Netbeans
javax.swing.JTextPane DocViewTextPane = new javax.swing.JTextPane();
// set text pane so it will behave as expected.
DocViewTextPane.setUI(new javax.swing.plaf.basic.BasicEditorPaneUI());


![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=1a451e79-4965-488b-8fd6-655e5bff22c7)
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=48e7f987-65b6-45e6-b2f6-a5a548f53a2b)