When should I write my own Java Swing Look and Feel instead of customizing it?
I've used several different Look and Feels for Java Swing, but I don't like anyone 100%, so I often end up tweaking it a lot. Sometimes I wonder if it is better to write my own LaF (by extending an existing one), but I really don't know.
At the moment I'm mostly using Nimbus , but I'm changing all the colors (to darker ones) and rewriting the look of some components like sliders and scrollbars. I am also basically customizing all the tables, and I am going to change the look of several other components.
When is it recommended to create a new Look-and-Feel instead of customizing it? What are the pros and cons?
those. customize the Nimbus or create a new one by expanding the Nimbus?
Further article: Creating a Custom Look and Feel (Old)
a source to share
When is it recommended to create a new Look-and-Feel instead of customization?
- If you want your application to look pretty much the same on every major platform
- When you want to get rid of the dead giveaway that your application is a Java application (which is of concern to some programmers selling commercial software to OS X users, where Java has a terribly bad reputation among users [this is undeserved, but true] ).
Here's an example of the disease you have to go through in order to grow a tiny bit of a pathetic JTable (by the way, the author of this blog later hired Apple):
http://explodingpixels.wordpress.com/2009/05/18/creating-a-better-jtable/
What are the benefits?
It is possible to make the application almost identical (the only difference is the font rendering, which is slightly different from OS X to Linux to Windows ... but it can be made quite close, or you can go with "non-AA" pixel-perfect fonts that will look completely identical).
and cons?
- Your application will not have an appearance.
- This is a lot of work (Swing is not easy: it's kind of an over-engineered, complex beast, and it's very hard to tell if it's "incredibly thoughtful" or "incredibly stupidly designed").
I've written a few custom Swing components that look exactly the same on Windows, Linux, and OS X (using pixel perfect fonts), but I wouldn't write the whole LnF.
a source to share
Writing Java look and feel is not for the faint of heart. This is on its own, so I would argue that it is probably more efficient to find a pre-existing look and feel that suits your needs.
Kathryn Huxtable is working on the implementation of the Sea Glass Look and Feel , which was a pretty big deal. It is based on Nimbus, although Nimbus and its Swing framework are not as extensible as required to create a custom look. This means that most of the code must be copied and pasted into subclasses. You probably don't want it to be related to this when working on another project.
Synthetica is also another pre-existing option that I believe is quite affordable for working with skin.
a source to share