Java GUI frameworks. What to choose? Swing, SWT, AWT, SwingX, JGoodies, JavaFX, Apache Pivot? [closed]
There is quite a lot of gui frameworks out there for java, but what is recognized as today's framework of choice?
The following is my understanding of the different frameworks, please correct me if im wrong. This is a very loosely defined set of questions, but i still think its valuable for anyone thinking of creating rich gui applications.
AWT
Is the very foundation of swing, it performs well but is lacking in advanced components. If you intend to create rich applications, AWT is probably not the way to go. However for smaller gui applications that doesn't require rich user interfaces. This might suit perfectly as it's a tried and proven framework.
Swing
Based on AWT as previously stated. In its infancy it was regarded as slow and buggy and caused IBM to create SWT for Eclipse. However with Java 5 (or 6?) Swing became the framework of choice for building new applications. Swing has a lot of rich components but are still lacking in some areas. One example being that there isn't a full featured TreeTable component which can do sorting and filtering/searching.
SWT
Created by IBM for Eclipse, they seemed to think that Swing was not suited for Eclipse at the time. By itself is pretty low-level, and it uses the platform's native widgets through JNI. It is not related to Swing and AWT at all. Their API is however somewhat clunky and not intuitive. They do have some advanced component's like a TreeTable. (but i don't think they support sorting and filtering out of the box). SWT uses some native bindings (through JNI?) and the rant on the internet is that this framework should not be used in today's projects. (why not?)
SwingX
Based on Swing and it's mission is to create rich components for swing. Still under development. (not very active though.) Have a very nice set of components, like for example TreeTable. But the TreeTable does not support filtering and sorting as far as i know. It does however support searching with highlighting.
Note that SwingX is components (AFAIU) that are extensions or compositions of existing Swing components
JGoodies
A framework which i know nothing about... What is it's strengths and weaknesses? What set's Jgoodies apart from the rest?
JGoodies OTOH is about PLAFs and layouts.
JavaFX
The latest flagship of Java/Oracle. promising to be the facto standard in developing rich desktop or web applications.
Apache Pivot
It renders UI using Java2D, thus minimizing the impact of (IMO, bloated) legacies of Swing and AWT. (@Augustus Thoo)
It's main focus seems to be on RIA (Rich internet applications), but it seems it can also be applied to desktop applications. And as a personal comment, Looks very interesting! I Especially like that it's an apache project.
https://cwiki.apache.org/PIVOT/frequently-asked-questions-faq.html
Qt Jambi
A java wrapper to the native qt library which is written in c/c++. Very powerful, widely used and accepted. Has a lot of GUI components and a easy to use API.
http://qt-jambi.org/
So, to try to summarize a bit of what im asking:
Say i wanted to create a desktop application today in Java which involves a lot of advanced components, what should i choose? And why?
Which one of these frameworks should be recognized as deprecated and which should be recognized as the frameworks of the distant future?
What is todays de-facto-standard framework and which tools do you utilize to create java gui applications?
I might regret asking this, but ill try it anyways:
C#/.Net is said to have a very good set of easy to use components which can be flexed in every direction possible. And after investigating different java frameworks to some extent i can't seem to say the same about Java. Why is this? Why doesn't java (which is the most widely used programming language in the world) have the same set of GUI components?
Is it just that java has based their gui components at a much lower level, and it is possible to write all these advanced components that im looking for, but you have to do much if not all of the work yourself?
Solution 1:
Decision tree:
-
Frameworks like Qt and SWT need native DLLs. So you have to ask yourself: Are all necessary platforms supported? Can you package the native DLLs with your app?
See here, how to do this for SWT.
If you have a choice here, you should prefer Qt over SWT. Qt has been developed by people who understand UI and the desktop while SWT has been developed out of necessity to make Eclipse faster. It's more a performance patch for Java 1.4 than a UI framework. Without JFace, you're missing many major UI components or very important features of UI components (like filtering on tables).
If SWT is missing a feature that you need, the framework is somewhat hostile to extending it. For example, you can't extend any class in it (the classes aren't final, they just throw exceptions when the package of
this.getClass()
isn'torg.eclipse.swt
and you can't add new classes in that package because it's signed). -
If you need a native, pure Java solution, that leaves you with the rest. Let's start with AWT, Swing, SwingX - the Swing way.
AWT is outdated. Swing is outdated (maybe less so but not much work has been done on Swing for the past 10 years). You could argue that Swing was good to begin with but we all know that code rots. And that's especially true for UIs today.
That leaves you with SwingX. After a longer period of slow progress, development has picked up again. The major drawback with Swing is that it hangs on to some old ideas which very kind of bleeding edge 15 years ago but which feel "clumsy" today. For example, the table views do support filtering and sorting but you still have to configure this. You'll have to write a lot of boiler plate code just to get a decent UI that feels modern.
Another weak area is theming. As of today, there are a lot of themes around. See here for a top 10. But some are slow, some are buggy, some are incomplete. I hate it when I write a UI and users complain that something doesn't work for them because they selected an odd theme.
-
JGoodies is another layer on top of Swing, like SwingX. It tries to make Swing more pleasant to use. The web site looks great. Let's have a look at the tutorial ... hm ... still searching ... hang on. It seems that there is no documentation on the web site at all. Google to the rescue. Nope, no useful tutorials at all.
I'm not feeling confident with a UI framework that tries so hard to hide the documentation from potential new fans. That doesn't mean JGoodies is bad; I just couldn't find anything good to say about it but that it looks nice.
-
JavaFX. Great, stylish. Support is there but I feel it's more of a shiny toy than a serious UI framework. This feeling roots in the lack of complex UI components like tree tables. There is a webkit-based component to display HTML.
When it was introduced, my first thought was "five years too late." If your aim is a nice app for phones or web sites, good. If your aim is professional desktop application, make sure it delivers what you need.
-
Pivot. First time I heard about it. It's basically a new UI framework based on Java2D. So I gave it a try yesterday. No Swing, just tiny bit of AWT (
new Font(...)
).My first impression was a nice one. There is an extensive documentation that helps you getting started. Most of the examples come with live demos (Note: You must have Java enabled in your web browser; this is a security risk) in the web page, so you can see the code and the resulting application side by side.
In my experience, more effort goes into code than into documentation. By looking at the Pivot docs, a lot of effort must have went into the code. Note that there is currently a bug which prevents some of the examples to work (PIVOT-858) in your browser.
My second impression of Pivot is that it's easy to use. When I ran into a problem, I could usually solve it quickly by looking at an example. I'm missing a reference of all the styles which each component supports, though.
As with JavaFX, it's missing some higher level components like a tree table component (PIVOT-306). I didn't try lazy loading with the table view. My impression is that if the underlying model uses lazy loading, then that's enough.
Promising. If you can, give it a try.
Solution 2:
SWT by itself is pretty low-level, and it uses the platform's native widgets through JNI. It is not related to Swing and AWT at all. The Eclipse IDE and all Eclipse-based Rich Client Applications, like the Vuze BitTorrent client, are built using SWT. Also, if you are developing Eclipse plugins, you will typically use SWT.
I have been developing Eclipse-based applications and plugins for almost 5 years now, so I'm clearly biased. However, I also have extensive experience in working with SWT and the JFace UI toolkit, which is built on top of it. I have found JFace to be very rich and powerful; in some cases it might even be the main reason for choosing SWT. It enables you to whip up a working UI quite quickly, as long as it is IDE-like (with tables, trees, native controls, etc). Of course you can integrate your custom controls as well, but that takes some extra effort.
Solution 3:
I would like to suggest another framework: Apache Pivot http://pivot.apache.org/.
I tried it briefly and was impressed by what it can offer as an RIA (Rich Internet Application) framework ala Flash.
It renders UI using Java2D, thus minimizing the impact of (IMO, bloated) legacies of Swing and AWT.
Solution 4:
Swing + SwingX + Miglayout is my combination of choice. Miglayout is so much simpler than Swings perceived 200 different layout managers and much more powerful. Also, it provides you with the ability to "debug" your layouts, which is especially handy when creating complex layouts.
Solution 5:
Another option is to use Qt Jambi. It has nearly all the greatness of Qt (many components, good documentation, easy to use), without the hassle of C++. I used it 3-4 years ago for a small project, even then it was almost mature.
You might want to see the discussion about Swing vs. Qt here.