Tom Marble wrote:

 > What's broken with Swing?  And/or what makes you happy about SWT?
 >
 > If you are going to compare performance, do you have any side-by-side
 > comparisons?
 >
 > Thanks,
 >
 > --Tom
 >

Theres a loaded question :)

I broke this out into a new thread so it would stop ending up under a 
massive no-subject thread in my client...

I'll start with things that are annoying about swing from a development 
perspective.

Swings default layout managers pretty much suck.  They are overly 
difficult to use (especially the GridBagLayout), require large amounts 
of code, and when the code is done, someone looking at it won't have a 
clue what they actually look like until they see it run.

I stopped using suns layout managers the first time I saw the JGoodies 
forms layout manager (I learned about it when the author gave a 
presentation on it at JavaOne)

http://www.jgoodies.com/freeware/forms/index.html

Swing gui's created with the jgoodies tooling take about 15% of the 
layout code and get better results than an identical GridBagLayout.

Next, if you don't want to have a Swing application that "freezes" - or 
ceases to paint the screen whenever you are doing time-consuming 
calculations, you need to jump through a whole additional set of hoops 
to set up the threading and proper error handling in Suns Swing world. 
This is basic stuff - it shouldn't be difficult.  But sun manages to 
make it a pain.  Hence, most java apps that are written in swing simply 
stop painting the screen when they are doing something time consuming.

Luckily, someone else solved this problem with the Swing APIs.

http://foxtrot.sourceforge.net/

So now we have two things that Sun could take (or learn from) to vastly 
their APIs - but they don't do it.

I find that writing gui code in SWT is much easier, quicker, and 
intuitive.  Their API's are clean and consistent.  Their complex layout 
managers are much simpler to learn and easier to use than Sun's complex 
layout managers.  The overall learning curve is tiny compared to Swing.


Now, from the end user perspective of someone using a swing app - why 
doesn't the application look like all of my other standard applications?

Swing tries to emulate what the platform actually looks and behaves 
like, and while they do a reasonable job, they still don't get it right. 
   Sun is great at matching up 95% of the look and feel - and just 
letting the rest fall through the cracks.  Colors are slightly off, tab 
driven cursor movements don't always do the same thing that they do in 
native applications, etc.  Not to mention that the GUI is also slower 
than all native applications - which leads to the (wrong) impression 
that java is slow and can't perform on the desktop.  The problem really 
is Swing.

Have you seen the JFileChooser on Windows XP?  It doesn't look at all 
like a Windows XP file chooser.  And it is slow slow slow.

Oh, and of course, it only took them 2 years to write the Windows XP 
look and feel _after_ Windows XP had already been released.

How long do you suppose it will take Sun to emulate the new look and 
feel of "Windows++SuperCharged3.0" when it comes out?

And if a user customizes the look and feel of their desktop - none of 
those changes go through to a Swing app.  So it just looks bad.

In SWT - your users are presented with a GUI that looks like they expect 
it to look - on whatever platform they are using.  Everything behaves 
exactly as they are used to - because it is all using native widgets.

If your users customize their system colors, fonts, etc - everything 
carries through to your SWT application.

I have also found the SWT developers to be _much_ more responsive to 
fixing bugs that the Swing developers.  Of the two bugs I have found and 
reported - both were fixed in < 3 days.

The bug I discovered just yesterday in the 1.5 jdks that was really the 
final straw for me - If you launch a swing application with the -Xmx 
parameter to set the max heap size - and you set it to more than 1059M - 
Swing refuses to paint the text of any component in your application.

I don't even want to think of what kind of code they have under the 
covers that could cause an error like that.

One final point - how many _popular_ end user applications have ever 
been written in Swing?  JBuilder, NetBeans - about the only things I can 
think of is developer tools.   Its been around for how many years?  Is 
it more than 10 yet?  Any platform with as small of a user base as Swing 
should be looked at as a complete failure after this long.

Here is an application written in SWT - and it looks so nice and works 
so well that most end users wouldn't even recognize as being a java 
application.  And thats a good thing, given java's reputation on the 
desktop.

http://azureus.sourceforge.net/

Dan


-- 
****************************
Daniel Armbrust
Biomedical Informatics
Mayo Clinic Rochester
daniel.armbrust(at)mayo.edu
http://informatics.mayo.edu/