[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ajug-members]: Swing or SWT?



John Wells wrote:
> I would like to develop this particular app in Java, but am unsure
> what our best option is.  The app will quite honestly never be run on
> any other platform other than Windows, and I'd like to make the look
> and feel as Window-y as possible.
> 
> speed increase as well as native look and feel, while potentially
> sacrificing some portability.
> 
> The final important requirement in our case is keeping the package
> the GUI is distributed in as small as possible.  I'm not certain, but
> I suspect that packaging the SWT libs along with the app could
> increase package size substantially.
> 
> Anyone on the list faced this decision before?  What did you decide
> or what would you suggest?

A while ago we faced the same sort of decision at a small company I used 
to work for.  We were developing a prototype application that 
demonstrated the capabilities of a new product, and we wanted to mimic 
the "native" look and feel of the platform as much as possible.

Eclipse had been stable with the 2.x series releases for a while, and we 
were up for a learning challenge, so we chose SWT.  Although there 
weren't many docs about SWT at the time (only a pile of code snippets 
and an API), I had no problems picking it up in a few hours.

My original impressions were very positive.  They have used a lot of 
nifty tricks in SWT.  The API is pretty consistent, the method names are 
the same, and they do what you'd expect them to, which leads me into 
what I think is the most profound thing I discovered when working with 
SWT: it just worked.  I'll admit, Swing isn't exactly rocket science, 
but I found my self looking like the guy in the Troll Tech logo more 
than once when I wrote some code, ran it, and the UI did exactly what I 
expected.  Unfortunately for Swing, I can't say I have always enjoyed 
such smooth sailing.

Another feature of SWT I enjoyed was the simple, powerful, yet intuitive 
FormLayout manager.  It combines most of the power of Swing's GridBag 
with a relatively simple interface that is pretty enjoyable to write by 
hand.  It's a shame Sun never did anything quite like this when I was 
using Swing...

And for those stalwarts out there who will undoubtedly say "you lose the 
ability to use all of the wonderful pre-built components for Swing," the 
3.0 SWT drops have support for using AWT (and, by induction, Swing) 
components inside of an SWT application.  I have used it with JFreeChart 
with much success (even the Swing printing worked flawlessly).

With respect to size concerns, SWT will add about 1.5mb to your 
distribution, which isn't a whole lot for what you get (the native 
look/feel on any platform, not just Sun's attempt to clone it).  Either 
way, it is definitely worth a second look.

SWT resources:
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html

Swing widgets in SWT:
http://www.jfree.org/phpBB2/viewtopic.php?t=4693&highlight=swt

-- 
Robert Gash (Vice President, AJUG)
gashalot@gashalot.com, http://www.gashalot.com
AIM: gashalot, Jabber: gashalot@jabber.org, Yahoo: gashalot