views:

211

answers:

6

Hi there,

I mainly developing JEE and now I'm in a situation where I need to write a small native Java app. But tbh I'm a little bit lost, which frameworks (SWING, SWT, etc.) are outthere? Is some rapid dev also possible with one of these? Maybe someone could provide me some links or share his experiences.

Thanks!

+1  A: 

I had a similar thing to do a while back. I finally settled on Swing App Framework because it does not try to be the one framework to rule them all.

In the end I wrote the little app, had no surprises, the code turned out to be pretty clean (including uploading in a ackground task), the customer is happy, I am happy.

It aims to provide (stolen from the blurp)

  • Application lifecyle, notably GUI startup and shutdown.
  • Support for managing and loading resources, like strings, formatted messages, images, colors, fonts, and other types common to desktop applications.
  • Support for defining, managing, and binding Actions, including Actions that run asynchronously (in the "background").
  • Persistent session state: support for automatically and selectively saving GUI state from one run of an application to the next.

which was exactly what I needed.

Warning: there appears to be little life in this framework as the driving force is rumored to have left Sun/Oracle a while back.

Update: some devs have forked in Project Kenai under the name 'Better Swing Application Framework'. So there may be life after death after all

Peter Tillemans
also,swing libraries come bundled with the JDK,unlike SWT
Phobia
True that was also a consideration. I have also done eclipse RCP and plugins in the past, but I found the overhead too high for a simple little tool. Also I develop under ubuntu and deploy on windows so I did not have to deal with different SWT binaries. All small things, but they add up:
Peter Tillemans
A: 

Take a look at Apache Pivot. It is meant to be a higher level more modern framework than just plain Swing, that still uses Java instead of going all the way to JavaFX. It positions itself as an RIA toolkit, but it can just as easily be used for standalone desktop apps. From the website:

Apache Pivot is an open-source platform for building rich internet applications in Java. It combines the enhanced productivity and usability features of a modern RIA toolkit with the robustness of the Java platform. Pivot applications are written using a combination of Java and XML and can be run either as an applet or as a standalone, optionally offline, desktop application. [...] Pivot includes additional features that make building modern GUI applications much easier, including declarative UI, data binding, effects and transitions, and web services integration.

Russell Leggett
+2  A: 

Swing and SWT are the two main candidates, yes. JavaFX also comes to mind, but I think it's not yet ready for prime time: it had no UI editing tool worth speaking of for a long time, the only enterprise UI prototype I know of in real life was a fiasco...

Swing and SWT are the two you might think about. It's basic advantages are:

  • more platform independent
  • more consistent in terms of performance
  • better free UI designer (NetBeans)
  • extremely flexible
  • can be used in JavaFX

SWT's advantages are:

  • simpler API
  • uses native UI widgets when it can (the UI is more similar to other apps in the same environment)
  • at some point, it was argued that it's faster than Swing, although this was on Windows only

Quite advanced rich client frameworks exist for both (NetBeans Platform and Eclipse RCP) and if you plan on building anything non-trivial, I would heartily suggest you use one of these: you get modularized apps, update mechanisms, context-sensitive help, consistent actions over menus, hotkeys and toolbars, window management and lots of other excellent features for free.

I worked with Swing and prefer it over SWT as it has a purer component model (with SWT you have to worry about freeing resources, as you're using native widgets), is truly multi-platform (SWT works on Windows, MacOS and Linux, and is not even very well optimized for all three), and it's more customizable.

You're probably not making a mistake trying SWT or even JavaFX, but I'd be hard-pressed to find a good reason to switch to SWT and would try JavaFx only to check the state of the art, assuming the apps is just a showcase app.

I could sprinkle a couple of links, but you can easily google for yourself and find the results than interest you.

Tomislav Nakic-Alfirevic
+1  A: 

The free NetBeans IDE has a visual layout tool for both Swing and JavaFX.

Marcus Adams
A: 

i recommend against using a layout tool; the code is very hard to read and maintain.

also, if you need database access to objects, then netbeans will leave entity managers open and create major headaches and bugs later if your app needs to use more than one thread.

Jill Renee
+1  A: 

There are also GUI frameworks that are not written in Java which might serve your purposes. For example, GTK+ is written in C but there are language bindings to Java. Check out java-gnome for example.

I don't know how good it is, but a quick Google search also turned up Java bindings for Qt so maybe that's also worth looking into.

bratsche