tags:

views:

338

answers:

8

I need to create a GUI application in Java. I just realized that I have different optional ways to go (SWT and Swing are among them).

I have already found out that there is a lot of discussions about what way is better and I do not want to go to deep into these discussions (I am a newbie).

I do not care about all aspects of the dilemma. I just have a few main requirements listed bellow:

  1. It should be easy to use (easy to create what I want).
  2. In the end I would like to have just one file which can be easily executed (without any additional tricks, settings and installations).
  3. It should be platform independent. Or more specifically, the application should work fine on Window and Ubuntu.
+6  A: 

Based on your requirements, I would say Swing. SWT has a more platform-specific look about it but Java ships with Swing built-in, there's no messing about with external libraries as with SWT although the use of Eclipse may make that much easier (I still develop quite a bit of my stuff from the command line unfortunately).

They're both easy in terms of use (well, easy once you get used to layout managers) and will work fine under both your desired platforms but since the only differentiator you seem to care about is the "without any additional tricks, settings and installations", I would stick with Swing.

That's my advice. Feel free to accept or ignore or even call me an old coot. I won't take offence :-)

paxdiablo
+2  A: 

I would suggest that you use Java's Swing libraries if you are not familiar with Java GUI development. They are very well documented, and there are lots of tutorials on-line, including on Sun's Java website (here).

GUI development in Java is not very straightforward, but the tools available are getting better all the time. I would suggest you try out the NetBeans IDE that has a nice visual designer for GUI components. I have not used the Eclipse IDE's GUI designer, but I gather its good as well. You will need to get your head around the MVC pattern, but it should be a good learning experience.

In short, my vote goes for using Swing/JFC, especially if you are new to Java GUI development.

EDIT - You can control the look and feel of a Java APP very easily. If you use the platform independent (Metal) look and feel, your GUI will look pretty much identical on Windows and on Linux. Of course, a Java app will run just fine on Windows of *nux as long as there is a supported JVM installed.

Luhar
"JFC"? I've not heard it be called that in a long time ;-)
Joachim Sauer
I am 'old school' like that :-)
Luhar
+1  A: 

I find Netbeans' drag and drop visual editor and pre-wired Swing Desktop Application template much easier to use that what comes bundled with Eclipse, so I'd suggest that.

It'll automatically create an executable jar, and let you create a Java Web Start launcher if you wish as well. And being Java, it's OS-independent.

Here's a link to the quickstart tutorials.

JRL
+1  A: 

I cannot add comment yet because I'm new here (please mod me up so I can comment) but choosing Swing or SWT depends on the IDE you're using.

If you're using Eclipse, then both are fine.

If you're using the free IntelliJ IDEA community edition, you'll prefer to use Swing because the IDE's GUI editor is "Swing only".

I take it you're using Eclipse?

LowLevelAbstraction
Why comment? That is an answer, not a comment. But: SWT *is* more complex to deploy because you need to care about using the correct version and native library.
Joachim Sauer
You would decide between Swing or SWT for an application based on your preference of IDE? Is that not a bit donkey about great tit? Anyway, use gedit.
Tom Hawtin - tackline
A: 

From my experience, if you want easy to develop Swing is the way to go. If you need good performance, then SWT is a better bet.

NOTE: The last time I did GUI development in Java was 4 years ago.

tster
+1  A: 

Based on your requirements, I recommend using Swing:

  • SWT requires additional native libraries (violates item #2),
  • You are likely to find more instructional material on Swing (since you are a newbie),
  • Both solutions are somewhat platform independent and supported on both platform you mentioned but SWT is not equally supported on all platforms,
  • There are more WYSIWYG tools supporting Swing which may help with the learning curve.

Note that the APIs are similar and sometimes identical so learning one gives you a head start on the other.

Faron
+1  A: 

Swing,

SWT works on Ubuntu but not nearly as well as on Windows, that's at least my experience. The main reason to choose SWT is if you want to build your application on the Eclipse RCP framework( where you get a dockable views/editors, plugin mechanism, automatic updates, user roles. help browser, preference mechanism etc) or if you want your application to have that polished native look.

Kire Haglin
A: 

I just completed a two year project creating a buisiness application, so my focus was clearly on usability and speed.

My decision in the end clearly led to SWT, for the following reasons:

  • Buisiness users tend to use Terminal Servers and RDP for their apps. Every Swing app is very slow over RDP, because the app has to render every pixel again and again. Try using Photoshop or Gimp over RDP and start scrolling in an image. That is the performance you have with Swing in tables.
  • Some very good gui components are only available as COM objects. I wanted to be able to use those, and since 100% of all buisiness customers are Windows users, they accept the fact that your software only runs on Windows. (We have linux clients, too, but only for machine input terminals, that don't need the full blown Windows GUIs)
  • We use SWTDesigner as a GUI designer, which is as good as SwingDesigner für Swing (which both are the best GUI designers at all). They are worth the price tag if you have to create a few hundred masks.
  • Our GUI looks 100% native, honors the large fonts they use on their desktops, and feels fast.

We are very satisfied with SWT, but it has some downsides:

  • Native Java components are a bit rare. There is more on the Swing side of life.
Daniel