Java – Which Java GUI framework to choose now?


Which GUI framework/library would you choose if you were to start your new project now or in the near future?

It has to be free for commercial use and cross platform.

I have been a happy swing user, but Sun seems like pushing swing to deprecation, while pushing Javafx, which is not yet ready for prime time.

There's also SWT, but it seems like it has issues on Linux.

What is your Gui library/framework of choice?

EDIT: Sun has canceled swingx project. From the forum comments on seems like majority of Sun resources that previously worked on core swing are now developing JavaFx full time.

Best Solution

I think that despite Sun's mismanagement, Swing is still an excellent framework. You can do a lot with it, especially if that "lot" involves custom rendered UI controls. If your application needs a branded LAF, or even just a few complex custom controls here and there, Swing is exactly what you want.

On the other side of the coin, I do like SWT quite a lot. It gets a bad rap because everyone used to think it was IBM's ploy to take over Java, but it's really just another UI framework that is quite complementary to Swing. I would not advise using SWT for super-complex graphics rendering (specifically: compositing) or for creating really non-trivial custom controls, but for everything else it is really dandy. The API itself gets a lot of criticism because of things like reliance on bit masks and a user-managed event dispatch loop, but most of those things are pretty transparent once you get used to them. The components themselves are a lot simpler than Swing's (in terms of extensibility and similar), which means that the API can be proportionally simpler. I can actually remember how to create and populate a table in SWT; whereas I don't think I have ever handled that in Swing without Google's assistance.

SWT's biggest problem right now is the stable version depends on Carbon on Mac OS X. This means that SWT apps can only run 32bit on Java 5 (or 32bit on SoyLatte). As for other platforms, SWT is phenomenal on Windows (Vista and XP) and almost as good on GTK Linux. I have not (in recent past) had any issues with SWT on Linux, so I'm a bit surprised that you would mention it as a sore point.

Coming back to your question: it all depends on what your application needs. If it's a flashy custom-styled application with tons of custom controls and complex compositing, Swing is the only game in town. However, if a simpler API is more important to you, or if your users demand the ultimate in platform LAF fidelity, SWT is the best choice.