Java GUI frameworks. What to choose? Swing, SWT, AWT, SwingX, JGoodies, JavaFX, Apache Pivot? [closed]
Asked Answered
R

9

227

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?

Reasoned answered 9/9, 2011 at 8:6 Comment(4)
I wasn't aware that SWT was "based on a combination of AWT and Swing". Is that really the case? I thought it was pure JNI to invoke the OS's windowing system...Artificer
@Artificer Oh, it was said in one of the answers comments. I just assumed they knew what they were talking about.Reasoned
I think you confuse "UI Toolkit" and "GUI framework". AWT, Swing and SWT are UI toolkits but I would certainly not call them "frameworks". Frameworks are based upon a given UI toolkit and provide the glue to build your application. First, you should choose the UI toolkit and then choose a framework that works on that toolkit. FWIW, I would choose Swing with my own home-made Guts-GUI framework :-)Miley
It's almost always Swing vs. SWT (for me at least), for small comparison you could check What are the main things that an experienced Java SWT programmer should be aware of when moving to Swing?..Dermatologist
T
79

Decision tree:

  1. 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't org.eclipse.swt and you can't add new classes in that package because it's signed).

  2. 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.

  3. 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.

  4. 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.

  5. 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.

Transpire answered 9/6, 2012 at 11:17 Comment(3)
Tried Pivot demo "Kitchen sink", after opening some groups it keeps eating whole CPU. If it's because of Pivot design, then I definitely don't want it in my projects.Celinacelinda
Seems like I've found the source of problem and it's fixed in later versions: apache-pivot-users.399431.n3.nabble.com/…Celinacelinda
JavaFX 8 (for Java 8 and above) has a TreeTableView widget. However, JavaFX 2.2 (for Java 7) lacks this, and also lacks standard error and info dialgos: see https://mcmap.net/q/120160/-javafx-2-1-messagebox . Also the ControlsFX widget library is available for Java 8 only: fxexperience.com/controlsfxSabadell
S
12

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.

Subsumption answered 9/9, 2011 at 11:57 Comment(2)
In your opinion, would an advanced component like a TreeTable with column sorting and filtering be a big issue with SWT+JFace?Reasoned
@netbrain: I have done that numerous times, it's fairly straightforward with JFace. This is what I meant by an "IDE-like" interface, maybe not the best choice of words.Storm
V
9

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.

Visional answered 9/9, 2011 at 8:20 Comment(4)
I had the impression that netbrain was asking about desktop apps. For RIA frameworks, consider also GWT and Vaadin. These frameworks allow you to write in Java, compile and get JavaScript that runs very well on all common web browsers.Stortz
can't pivot be applied for desktop applications?Reasoned
Maybe it is a matter of definition, but RIA frameworks are basically designed to run in browsers.Stortz
@Reasoned : Yes, you can run Pivot as desktop app (JFrame) or applet (JApplet).Visional
M
9

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.

Mulish answered 9/9, 2011 at 14:15 Comment(0)
O
8

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.

Oleta answered 9/9, 2011 at 14:48 Comment(0)
K
5

My personal opinion: Go for Swing together with the NetBeans platform.

If you need advanced components (more than NetBeans offers) you can easily integrate SwingX without problems (or JGoodies) as the NetBeans platform is completely based on Swing.

I would not start a large desktop application (or one that is going to be large) without a good platform that is build upon the underlying UI framework.

The other option is SWT together with the Eclipse RCP, but it's harder (though not impossible) to integrate "pure" Swing components into such an application.

The learning curve is a bit steep for the NetBeans platform (although I guess that's true for Eclipse as well) but there are some good books around which I would highly recommend.

Kaciekacy answered 9/9, 2011 at 8:21 Comment(3)
Note that SwingX is components (AFAIU) that are extensions or compositions of existing Swing components. JGoodies OTOH is about PLAFs and layouts. But as you said, either will integrate seamlessly with Swing.Ghat
+1 Base your development on Swing. Swing is built on top of AWT and includes light-weight components that look and behave the same on all platforms, so you never should use AWT components directly. There is a large number of excellent Beans you could easily add to your development GUI like i.e. toedter.com JCalendar.Stortz
@Andrew in addition to PLAF and layout, JGoodies offers more: beans binding (for presentation model pattern), validation and a "JSR-296 like" framework (that one is commercial).Miley
A
3

you forgot for Java Desktop Aplication based on JSR296 as built-in Swing Framework in NetBeans

excluding AWT and JavaFX are all of your desribed frameworks are based on Swing, if you'll start with Swing then you'd be understand (clearly) for all these Swing's (Based Frameworks)

ATW, SWT (Eclipse), Java Desktop Aplication(Netbeans), SwingX, JGoodies

all there frameworks (I don't know something more about JGoodies) incl. JavaFX haven't long time any progress, lots of Swing's Based Frameworks are stoped, if not then without newest version

just my view - best of them is SwingX, but required deepest knowledge about Swing,

Look and Feel for Swing's Based Frameworks

Aerobiology answered 9/9, 2011 at 8:40 Comment(5)
part of them on AWT Components, part on Swing JCompoentns, but between AWT and Swing is difference with implemented, accesible and inherits methods, for example Swing JComponents directly (API) implements lots of inherit or nested methods directly from AWT :-)Aerobiology
The JSR296 is dead. It is no longer "maintained" and the support for it has been removed from NetBeans. (And it never was a really good framework to start with)Kaciekacy
@a_horse_with_no_name that right with same progress in SWT, SwingX, new owner, new maniersAerobiology
SWT, developed by IBM, is not based on Swing, it is/was a competing technology. Swing uses AWT. JavaFX isn't based on Swing either. It is an entirely new framework. Some are calling it the successor to Swing, but it's still too immature to call that battle. I am making the exact same decision at the moment, and Swing is my candidate, simply for the fact that it is the most mature, yet realistic option available.Laney
SwingX is extensions to Swing (which is why it requires Swing knowledge), in fact, some of SwingX's features have been rolled into Swing itself.Laney
P
3

I've been quite happy with Swing for the desktop applications I've been involved in. However, I do share your view on Swing not offering advanced components. What I've done in these cases is to go for JIDE. It's not free, but not that pricey either and it gives you a whole lot more tools under your belt. Specifically, they do offer a filterable TreeTable.

Photosensitive answered 9/9, 2011 at 8:45 Comment(2)
Good to know! So JIDE has created their own components based on Swing...Reasoned
Yes, JIDE has made quite a few components covering grids, trees, tables, graphs and the like. Like I said, it's not free but given the time it would take to make these things yourself your'e probably better off using something that is already made. Furthermore, as far as I understand, JIDE is flexible with regards to letting open source projects use their components in exchange for a link to their website or a logo in the 'About' dialog.Photosensitive
H
3

I would go with Swing. For layout I would use JGoodies form layout. Its worth studying the white paper on the Form Layout here - http://www.jgoodies.com/freeware/forms/

Also if you are going to start developing a huge desktop application, you will definitely need a framework. Others have pointed out the netbeans framework. I didnt like it much so wrote a new one that we now use in my company. I have put it onto sourceforge, but didnt find the time to document it much. Here's the link to browse the code:

http://swingobj.svn.sourceforge.net/viewvc/swingobj/

The showcase should show you how to do a simple logon actually..

Let me know if you have any questions on it I could help.

Hymnology answered 9/9, 2011 at 9:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.