Adam Bien's Weblog

Sunday Jun 22, 2008

Would Someone Consider To Use SWT (or another native widget library) Again These Days For Portable Platforms / Applications?

Everything started with AWT in JDK 1.0. It came with JDK 1.0, and it used (actually uses - is still there) native widgets for rendering. I still remember the excitement, as it was introduced around 1998 (with JDK 1.2). Everyone was excited, although even the JTextFields weren't rendered correctly. Swing took the opposite approach - it rendered the components itself - so it was somehow OS independent. Only about three years later Eclipse was introduced with the SWT. It took similar approach to AWT - because of responsiveness problems of Swing and the native look and feel. At the time it was a viable solution for a given problem (although e.g. the performance of other Swing apps was really good). These days the responsiveness of Swing is just phenomenal (just ask IntelliJ / Netbeans users about it :-)), and Eclipse (forms) looks very different to the native Windows applications (Outlook, Office, OneNote etc.). The new platforms like Flex, Silverlight, even Java FX do not even try to achieve a perfect, native, look and feel - many nice demos just look totally different (which can be a good thing).

A native UI toolkit is harder too maintain for different platforms, because you have to test different operating systems (32 and 64 bits), and emulate some widgets, since they are not available for every given platform. So there is more effort to achieve the same goal (a decent toolkit). Furthermore SWT can only wrap existing native widgets, so the usable API is somehow limited. It's not always fun to work with it. Just ask a developer (after a beer) with SWT / JFace experience, whether he reall enjoyed it. You will get interesting answers :-).

Regarding the maintanenance overhead and portabilities issues - it remains really interesting question. Would e.g. Eclipse start with SWT again - or provide a lightweight approach?


Special Event: Java 8 with Java EE 7: "More Power with Less Code", 13th October, 2014

A book about rethinking Java EE Patterns

Comments:

hello Adam,
After a finger moved, long time gone.
nuxeo(I call it new XO) proivder a xform builder which use SWT/JFace and forms. It seems fine. new xo do content management(enterprise:).
And myself, created a new object notation language, I call it ON or CON, and create a SWT form builder, which used in myself biz process project. In old plan, I hope employ new xo xform implementation, but at last, I turned, because I not like xml now, I do ON, and seems work fine too.:)
As to others, E4 seems hot in dev list, but IMHO, the problem is XML and EMF. of cause If E4 employ ON style, I would much haaaappy.
Regards
Qinxian

Posted by qinxian on June 23, 2008 at 05:18 AM CEST #

Qinxian,

nice to meet you again - so you like native widgets?

regards,

adam

Posted by Adam Bien on June 23, 2008 at 12:43 PM CEST #

I'd always prefer the limitations that SWT imposes on my UI to the limitations that (at least out of the box) Swing imposes.
For example I hate the Swing "open file" dialog on Windows, the dialog offers roughly 25% of the native functions.

I think the SWT approach has it's merits, as does the non-native approach where the aim is to achieve the same look on all platforms.

Posted by Patrick Schriner on June 23, 2008 at 01:07 PM CEST #

Yeah - if you ask SWT/JFace developer after few beers they will tell you SWT sucks? Everything sucks - and by the way if you ask Swing developer about Swing they will get another beer and get drunk :)

I used both SWT/JFace and AWT/Swing APIs - not enough space in the comment to describe it but SWT really rocks - you cannot compare it to AWT. It's new quality of programming UIs. Comparing JFace with Swing is like comparing Mercedes with Trabant.

Cheers!

Posted by przemek on June 23, 2008 at 01:09 PM CEST #

Patrick,

yes, but the File Dialog could be easily fixed, in case it is broken. It is "just" a bug. I think it is perfectly possible to build a decent file dialog with swing. The question is - would "we" start with the native approach again, or just improve Swing?

thanks!,
adam

Posted by Adam Bien on June 23, 2008 at 01:10 PM CEST #

Adam,

it's just a tiny sample. Whenever I asked about this "problem" the only answer I got was: "who would want to rename a file in an 'open file' dialog" - which is not the point, but proves that it's not really seen as a bug (real bug for that same dialog: there is no minimal size, you can resize it to something totally unusable). The whole point of Swing is to provide the same or very similar L&F on all platforms, and that leads to a "least common denominator" approach, except that you can customize everything the way you like. The one thing Swing doesn't solve is the app that *wants* to have different L&F (beyond key bindings and graphics - that's all "look" , but not "feel").

That's why I think having both Swing and SWT is perfectly fine. I am happy that "rich" UIs (like the Silverlight / JavaFX Demos you mentioned) have *not* found widespread use, I don't want to learn a new set of L&F for every app.

My opinion would be: Swing as is (attitude-wise) *cannot* be used for all scenarios. The same is true for SWT. But that's not a problem, diversity is king. Swing was stagnant until Swt came up.

I (personally) prefer the native, platform-specific L&F to the emulated generalized approach.

Posted by Patrick Schriner on June 23, 2008 at 03:01 PM CEST #

Adam,

it's just a tiny sample. Whenever I asked about this "problem" the only answer I got was: "who would want to rename a file in an 'open file' dialog" - which is not the point, but proves that it's not really seen as a bug (real bug for that same dialog: there is no minimal size, you can resize it to something totally unusable). The whole point of Swing is to provide the same or very similar L&F on all platforms, and that leads to a "least common denominator" approach, except that you can customize everything the way you like. The one thing Swing doesn't solve is the app that *wants* to have different L&F (beyond key bindings and graphics - that's all "look" , but not "feel").

Posted by Patrick Schriner on June 23, 2008 at 03:02 PM CEST #

That's why I think having both Swing and SWT is perfectly fine. I am happy that "rich" UIs (like the Silverlight / JavaFX Demos you mentioned) have *not* found widespread use, I don't want to learn a new set of L&F for every app.

My opinion would be: Swing as is (attitude-wise) *cannot* be used for all scenarios. The same is true for SWT. But that's not a problem, diversity is king. Swing was stagnant until Swt came up.

I (personally) prefer the native, platform-specific L&F to the emulated generalized approach.

Posted by Patrick Schriner on June 23, 2008 at 03:02 PM CEST #

Adam,
At right now, you can say I prefer native style.
But in future, It should be both. And but what's future?:)
Regards,
Qinxian

Posted by qinxian on June 23, 2008 at 05:20 PM CEST #

Qinxian,

I love your comments!,

adam

Posted by Adam Bien on June 23, 2008 at 05:51 PM CEST #

Two comments in favour of SWT:

On Linux I prefer SWT, since SWT-GTK integrates very nicely into the rest of my UIs. Especially with a cross-toolkit style like QtCurve. So all QT, GTK and SWT apps look exactly the same - even when changing color schemes. On Windows this may be a different story, since the Windows LnF of Swing is close to perfect, while the Gtk LnF is still horrible - even with Java 6.

Then I attended the Eclipse Forum Opening at JAX 2008. And if it is true what they said, SWT will have a comeback soon with their SWT-Web... when I can create a UI just as a local UI, but run it remotely using a Flash player.

Posted by Carsten Schlipf on June 24, 2008 at 12:17 AM CEST #

Carsten,

I just wanted to hightlight the programming experience, and not necessarily the Look And Feel.

And you like the programming model?

See you at the w-jax? :-)

regards,

adam

Posted by Adam Bien on June 24, 2008 at 11:12 AM CEST #

Hi Adam,
As always "It depends" ;)
If you are heading for low memory consumption, and good integration with the OS, Native Widgets certainly have advantages.

Regarding memory consumption (shameless plug)
check http://kohlerm.blogspot.com/2008/06/classical-finalizer-problem-in-netbeans.html.
It seems that Swing needs to do additional buffering( maybe that can be fixed).

Regards,
Markus

Posted by Markus Kohler on June 26, 2008 at 12:22 PM CEST #

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