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?


[This entry is based on / extends my books: Enterprise Architekturen, Leitfaden fuer effiziente Software-Entwicklung and: Java EE 5 Architekturen, Patterns und Idiome]

 Subscribe in a reader

Kommentare:

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

Gesendet von qinxian am June 23, 2008 at 03:18 AM CEST #

Qinxian,

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

regards,

adam

Gesendet von Adam Bien am June 23, 2008 at 10:43 AM 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.

Gesendet von Patrick Schriner am June 23, 2008 at 11:07 AM 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!

Gesendet von przemek am June 23, 2008 at 11:09 AM 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

Gesendet von Adam Bien am June 23, 2008 at 11:10 AM 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.

Gesendet von Patrick Schriner am June 23, 2008 at 01: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").

Gesendet von Patrick Schriner am June 23, 2008 at 01: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.

Gesendet von Patrick Schriner am June 23, 2008 at 01: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

Gesendet von qinxian am June 23, 2008 at 03:20 PM CEST #

Qinxian,

I love your comments!,

adam

Gesendet von Adam Bien am June 23, 2008 at 03: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.

Gesendet von Carsten Schlipf am June 23, 2008 at 10:17 PM 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

Gesendet von Adam Bien am June 24, 2008 at 09: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

Gesendet von Markus Kohler am June 26, 2008 at 10:22 AM CEST #

Senden Sie einen Kommentar:
  • HTML Syntax: Ausgeschaltet
About,RSS / Atom

About me: www.adam-bien.com
JavaONE 2008 Interview
My Recent Books
Adverts
Search
Links
greenfire.dev.java.net
...the last 150 posts
my.netbeans.org
Visitors
License