Who loves the SWT programming model?

I gathered my experience in three different Eclipse-RCP with SWT projects. I asked also some other Java developers involved in the development of RCP/SWT applications.
Our opinions were very similar. RCP is great, but SWT..., especially tables [I try to stay neutral here]. I have to admit, that I started with Swing, so switching to SWT is perhaps not easily possible :-).
I'm really interested, whether is someone out there who loves developing SWT. If yes why? Your comments are really appreciated. I know people who like Swing, but who loves to develop applications with SWT?
I'm already looking forward for your comments.


I found one http://www.eclipsezone.com/eclipse/forums/t78418.rhtml

Posted by Carsten Saager on September 13, 2006 at 02:46 PM CEST #

And you? :-)

Posted by Adam Bien on September 13, 2006 at 03:18 PM CEST #

I found JFace quite refreshing, once I understood how a TableViewer works. SWT is just the bare bones UI stuff, AFAIK, no model included.

Posted by Tobias on September 14, 2006 at 01:39 PM CEST #

Hi Tobias,

JFace and SWT are "refreshing". Do you like them more then Swing?

Posted by Adam Bien on September 16, 2006 at 12:52 PM CEST #

I agree with Tobias. You need to use viewers, not plain SWT widgets.

Posted by eu on September 18, 2006 at 10:27 AM CEST #

JFace rocks! But it's true that using only SWT is not so good as SWING...

Posted by Diego Guidi on September 18, 2006 at 06:55 PM CEST #

Most people I know used SWT/JFace for the speed of native widgets. Since JSE 5, that argument has fallen off considerably.

So why consider using JFace/SWT if Swing works for you?

Posted by Rob Abbe on September 19, 2006 at 04:43 AM CEST #

I do. :-) I find the API much cleaner and more untuative than Swing. Granted, Swing's API is much more powerful.

Posted by Daniel Spiewak on September 19, 2006 at 05:08 AM CEST #

Rob, Maybe SWT is being considered because it's native to the Eclipse framework. It's true you can write Swing applications using Equinox and some bare-bones Eclipse plugins, but to really get everything you can out of the Eclipse framework you'll probably end up using SWT, whether you like it or not ;-)

Posted by Guy Pascarella on September 19, 2006 at 05:21 AM CEST #

After some SWT(JFace)/RCP projects I have to say:
- RCP is nice and works. Saves some work.
- SWT is not cross plattform, we had a lot of bugs on Linux and MacOS X (not firing events, non working tables), features which worked on XP
- SWT has to faces: Components which are used in Eclipse work, others which are not used in Eclipse are bug
- SWT is very hard to extend, should your customer be not satisfied with the standard widgets

Never tried Netbeans RCP, but I hope to use it in the next project instead of Eclipse RCP.

(Swing has it's own problems, event thread and no easy facedes to name just two)

Posted by Stephan Schmidt on September 19, 2006 at 04:15 PM CEST #


I have to completely acknowledge with you. It is also my experience. I will write a conclusion in a seperate entry,

thank you for your comment!

Posted by Adam Bien on September 19, 2006 at 09:21 PM CEST #

First, SWT is considered lighter weight than Swing.
And second, Eclipse is a big plus for SWT. Once I worked in a Swing-based project which later was integrated into Eclipse RCP. We had to adjust our Swing dialogs in the same layout and the theme of Eclipse JFace-based wizards and dialogs, which wasted lots of times. More popular Eclipse RCP becomes, more chances will I choose SWT instead of Swing.

Posted by Zhou Renjian on September 19, 2006 at 10:49 PM CEST #

I agree with Stephan,

there are still swt/jface bugs on Linux and MacOS, many widgets are even painted because the platforms does not support them natively.

>SWT is very hard to extend,...
thats true, if you want to implement something special in SWT/JFace (or not standard ;-) your code will start to look like a big recursive workaround ;-). In one case we needed a TableViewer without scrollbars. I thought, no problem we simple remove the scrollbar style flag and they are away, wrong this would be too easy. After asking around, googleing and reading in the doc i found nothing. I tryed to make them invisible, i disabled them but they are scrolling happy as before. After I debuged the Table widget, I found one small comment in the source: "feature on windows; Tables can not be created without scrollbars". Now its funny but after 2h of research it wasnt;-) After that we hacked a ResizeTableLayout which calculates the table size every time the model changed. It worked but not always. I learnd from that Table, now I read the swt/jface source first, and at last I open the doc. That is just the smallest sample of standard widget behavior.
@Tobias yes Viewers are realy "refreshing" see
I have posted a sample of badly implemented getters/setters in jface

But to answer the question, I personally dont like the programming model of swt. At the beginning of SWT everyone said that the most seen beginner mistake on swing is to forget to add your component to the parent and in SWT it can not happen. I never understood that because as beginner I have never forgotten to add a component because it was the first and easiest thing you made. In the other hand the model has a big drawback. You always NEED a parent if you create a widget. Sometimes it would be realy usefull to have a reference to the widget before setting the parent - not possible.
Additionally you can make with jface mistakes which would not happen in swing. In my last RCP project the client developer all agread that the GridLayout must be broken the widgets all dancing and flying around if you scroll or resize one of them, I was skeptical because it was at the time of eclipse3.0 and I was sure that the GridLayout is one of the most powerfull (or useable) layout managers of jface. After a code review I found the bug. Everyone reused the GridData object if possible, they said: "it is much cleaner if you have a few GridDatas and not 50 in every createContents() method." The problem was that jface stores many states in the LayoutData objects and if you reuse them, well the GUI starts to move ;-) But after one day of team refactoring it was solved.
Compered to the "dont forget to add the component" pitfall this one is a little bit more heavyweight :-) in my opinion.

In my opinion many reasons which lead some projects to use the eclipse way are not more valid. We have fast, hardware accelerated Swing and if we really want that our program looks native, it looks native. Even eclipse does not look native. If you need a plugin system you can still choose between the eclpse and netbeans RCP.

After my personal eclipse hype I am slowly switching back to swing, and with Matisse it had never been easier before ;-)

Posted by Michael Bien on September 19, 2006 at 11:50 PM CEST #

Oh, and I forgot: lots of widgets on MacOS X don't look native at all with SWT, whereas they look completly native with Swing. Funny, if you think about the "more native" claim by SWT.

Posted by Stephan Schmidt on September 19, 2006 at 11:59 PM CEST #

Another question: Does eclipse looks like a window app? :-)

Posted by Adam Bien on September 20, 2006 at 09:50 AM CEST #


thank you for your comment. Should be a new entry :-).
Last week I had to write an excel like table with Swing (after years of not using it). The great advantage in my opinion was: I know that everything is possible and extendible. My customer had precise requirements about resizing, scrollbars and wanted even a table as a header of the main table. We were able to solve all challenges in about half day.
Swing is not simple, but consistent. In my opinion also object oriented - you simple have to learn it with no suprises :-). There are special "setters" which do more than expected but - nothing is perfect :-).

Thank you. I will write a summary of the comment in a next entry.

I think also JFace is a perfect sample for leaky abstractions. You can use JFace as a decorator, but the existence of SWT is not fully transparent.

Posted by Adam Bien on September 20, 2006 at 09:57 AM CEST #


I agree with you in this point: Eclipse RCP is powerful. In case you want to use RCP, you have to live with SWT.
Until now, no one really likes SWT, but uses it because of RCP (which is o.k.).

Posted by Adam Bien on September 20, 2006 at 10:02 AM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
...the last 150 posts
...the last 10 comments