views:

169

answers:

3

I have used a few different Look and Feels for Java Swing, but I don't really like anyone to 100% so I often end up with customizing it a lot. Sometimes I am thinking about if it is a better idea to write my own LaF (by extending an existing one), but I don't really know.

For the moment, I mostly use Nimbus, but I change all colors (to darker ones) and rewrite the appearance of some components, like sliders and scrollbars. I also mostly customize all tables and I am thinking about to change the look of a few other components.

When is it recommended to create a new Look-and-Feel instead of customizing one? What are the pros and cons?

I.e. customize Nimbus or create a new one by extending Nimbus?

Related article: Creating a Custom Look and Feel (old)

A: 

I don't think there are any answers to this question except for generalities like:

  • when the effort of applying the changes to the existing Look-and-Feel is greater than creating a new one, or

  • when you want to create a new Look-and-Feel for non-technical reasons.

Stephen C
A: 

If your desired look and feel is distinguished enough that you believe you could assert intellectual property rights for it, then perhaps a case could be made to write it from scratch. I'm not likely to make such a case.

You ask whether you should customize or extend. Really, what's the difference?

Glenn
+4  A: 

When is it recommended to create a new Look-and-Feel instead of customizing one?

  • When you want your app to look really nearly exactly the same on every major platform
  • When you want to get rid of "dead giveaways" that your app is a Java app (which is a concern for quite some programmers selling commercial software for OS X users, where Java has a terribly bad rep amongst users [it's undeserved, but it's a fact]).

Here's an example of the kind of sickness you have to go through to enhance a tiny bit the pathetic JTable (btw the author of this blog later got hired by Apple):

http://explodingpixels.wordpress.com/2009/05/18/creating-a-better-jtable/

What are the pros?

It is possible to make an app look nearly identical (the only difference being the font rendering, which slightly varies from OS X to Linux to Windows... but it can be made to be quite close, or you can go with "non AA" pixel-perfect fonts, that will look perfectly identical).

and cons?

  • You're app won't have a native look at all.
  • It's a lot of work (Swing ain't exactly easy: it's some kind of over-engineered, over-complicated beast and it's very difficult to tell if it's "incredibly smartly designed" or "incredibly dumbly designed").

I've written several custom Swing components looking exactly the same on Windows, Linux and OS X (using pixel-perfect fonts) but I wouldn't write an entire LnF.

Webinator
+1 - Good explanation
Romain Hippeau
Thanks. The last few lines was helpful.
Jonas