posted 20 years ago
I wouldn't say that SWT is superior, but is is a nice option. The biggest advantage that SWT has over Swing is that it does look exactly like a native GUI. I have also noticed a noticeably faster startup time for SWT apps over Swing apps, and SWT is also noticably more responsive on low-end windows machines than Swing. However, on high end machines, there is really no noticable difference, and some people have complained that SWT is slow on Linux (though I haven't given this a try recently myself... it may have improved).
As far as the programming model, I tend to prefer Swing... this is probably mostly just a personal bias, as I have used Swing much more than SWT, but SWT has a couple of features that are annoying to me. SWT requires you to explicitly destroy native resources that your application uses... this includes things like colors, fonts, and components. Some things are automatically handled for you, like child components are destroyed when you destroy a parent component. But others, like colors and fonts, require you to either destroy them yourself when you are done with them, or use a listener interface to destroy them when another specific component is destroyed. SWT layouts are also annoying. Almost every layout requires a specific layout helper class to be attached to the components to be layed out. Unfortunately, these are all treated as plain Objects, so if you change layouts but forget to change all the layout helpers, everything compiles fine, but you get a runtime class cast exception. Also, all child components have to have their parent component passed into their constructor, which is annoying compared to dynamically moving components around by add()ing them to different containers in Swing.
However, SWT is still evolving... it is still very new, and it is open source, so there are many sources where this change can come from. For now I mostly use Swing, but there are some cases, such as if one of the advantages I mentioned at the start of the post are very important requirements, where I would use SWT.
-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.