Monday August 01, 2005 Swing and SWT on Windows Vista
It looks like Charles isn't posting with his normal frequency, so this little tidbit hasn't gotten it's normal publicity. :)
It seems a Sun guy has posted some screenshots of various Java apps running in the newly beta'd Windows Vista.
Looking at the screenshots, you'll notice that the Java 1.4.2 and later Swing implementations do a kick butt job of reaching into the bowels of Windows for the right graphics to build a Swing GUI in a native look-n-feel way, but the comparitively native SWT has some kind of leftover peers for buttons, checkboxes and radio buttons.
My previous conclusion on SWT and Swing is that developers need to be conscious of what they're getting into and make the choice that's right for them. I still think that's the case for now. This is just one more datapoint for developers.
Admittedly, the Swing guys may have just done this engineering before Windows went Beta, but I doubt it (I'm not really in a position to know). I'm also sure the SWT guys will be all over this one. But what is the opportunity cost of trying to build/maintain all of the code that does the peer stuff on Windows (old and new), GTK, Mac OS, Motif, etc.?
( Aug 01 2005, 09:58:19 PM PDT ) Permalink Comments [7]
b) Question: what's the opportunity cost of Sun Java devs developing the initial Java2D pipeline, then the DirectX pipeline, then the OpenGL pipeline (which is useless for Java 5 as its off by default), then the Direct3D pipeline... all of that just to get the damn thing to render at a not-abysmal speed. Oh... I nearly forgot about the GTK native rendering stuff in the recent Mustang builds (where it's not sure whether that could really provide speed improvements at all, as it'll need some more optimization to make its speed usable, which in turn might need hardware acceleration to be acceptable support which... oh bugger... just can't be expected to be available on Linux and Co; Disclaimer: it's a development build, so speed issues can still get fixed.).
Not to mention that the SWT team uses much shorter release cycles than the JDK, so fixes for anything that could be deemed deemed wrong (by nitpickers) on Vista can be published long before any JDK update (no to mention that Eclipse will have a major new release before the Mustang beta comes out).
Talking about nitpicking: what about the GrayRect fixes or the SubPixelAntialiasing? You might have noticed that they, too, are in Mustang and won't be available until late 2006... And I believe all the FileDialog inconsistencies on Windows (no AutoComplete,...) haven't been adressed at all yet.
To sum up: I agree that people choosing a GUI toolkit should think well about that... and I just provided another couple of data point... (you're welcome).
Posted by murphee on August 02, 2005 at 02:01 AM PDT #
This post is filled with lies! So I'll keep my cool, and nicely lay out what is wrong with the post.
You say that SWT has leftover peers for buttons, checkboxes, and radio buttons. That's not correct - those are not leftover peers. Those are the real Microsoft controls - even in Vista. Everybody knows (or should) that SWT/Eclipse needs to have the Windows[XP|Vista] look and feel enabled. http://wiki.schubart.net/How_to_Make_Eclipse_Use_the_Windows_XP_Skin
By default, the look and feel in Eclipse is win2000 since Sun doesn't want to compile their java executable with the proper bits turned on. In fact, because of this choice - even AWT apps (that use native peers) look like windows 2000 apps on WinXP and I'm sure Vista as well. (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5049340)
Yes - there is cost to build a system that works on all the SWT supported platforms, but as evidenced by the screenshot - they are usually backwards compatible. So it only costs them to take advantage of new features of each platform. For example, SWT already supports advanced drawing capabilities with Cairo on X, and with GDI+ on windows. If longhorn speeds up some of their controls (using opengl or something along those lines), SWT doesn't have to do anything at all, it will automatically take advantage of them. Therein lies the core of the Native vs Emulated widge set.
Posted by Eclipse Fan on August 02, 2005 at 06:31 AM PDT #
As 'Eclipse Fan' said, this is a common misconception. The same thing happens in Windows XP if you don't have a javaw.exe.manifest installed. This is actually a problem with almost any program that wants to take advantage of Windows XP styling. Having the manifest file is like saying 'yes, I allow XP theme-ing in my application'.
Here is a Javalobby tip I wrote a ways back about this specific problem and how to reach the solution:
http://www.javalobby.org/forums/click.jspa?searchID=22201&messageID=91817240
If you want to argue the merits of SWT or Swing please try to do a little more legwork than this.
Regards,
R.J.
Posted by R.J. on August 02, 2005 at 06:43 AM PDT #
So I readily admitted the SWT guys were probably already all over it. I should have left room to say there may already be a solution. I would never intentionally post a lie.
I agree with you that Sun should include the manifest file with the JVM, assuming of course there isn't a technical problem with doing so (i.e. do AWT and old SWT apps break badly?). If that'd fixup the SWT rendering problem, then that's goodness for developers. I'll send my own vote for that bug.
Regarding the Direct X and OpenGL that are off by default in Java 5, my understanding is that's because there were too many buggy implementations out there that they couldn't deliver reliability. Anyone who has used a cheapo graphics card with some OGL program is probably familiar with this issue. If Windows Vista gets it right for most cards, then Swing and SWT will be able to benefit, right? And developers will have choice, right?
I won't delve further into the opportunity cost debate as, I suspect we won't see eye to eye on that one. :) I didn't post it, but thoughts of other OSs like VMS came up.
Finally, let me say, I don't think it should be a religious war. Do I wish there were cooperation on one toolkit? Yes. Do I think competition has brought something of value to developers? Yes. If you peel back your own enthusiasim for SWT, I think you'd have to admit the Swing guys (and the JDNC project, etc.) have built some good stuff, right?
Posted by Matt Ingenthron on August 02, 2005 at 10:27 AM PDT #
[Quote]Finally, let me say, I don't think it should be a religious war. Do I wish there were cooperation on one toolkit? Yes. Do I think competition has brought something of value to developers? Yes. If you peel back your own enthusiasim for SWT, I think you'd have to admit the Swing guys (and the JDNC project, etc.) have built some good stuff, right?[/Quote]
Matt,
I couldn't agree more, well said. I am actually a strong Swing supporter, but I am in a difficult position, because I am also a strong Eclipse supporter. I hate the evangelism/FUD battle, no matter where it comes from. I would have loved for Eclipse to be built with Swing. As I have said on my blog, however, I'm more concerned about the effectiveness of the tool than I am by the 'evilness' of its implementation.
I personally *love* Swing; and the past year Sun has done an *outstanding* job of opening their closed doors on the Java enhancement process. Every day their communication with the Java community has increased; that can only mean good things for Swing. Grey rectangle is gone, sub-pixel anti-aliasing is in, and MVM discussions create a fury of discussion that Sun actually participates in. Things are *definitely* going in the right direction.
Regards,
R.J.
Posted by R.J. on August 02, 2005 at 12:41 PM PDT #
Good to hear R.J. Personally, I think in any of these religious wars, the majority are silent and just want options and things to interoperate. It's the rabid advocacy for <EM>only</EM> one position or the other that makes it look like a battle.
I make my measley opinion known in Sun in these areas (though I'm not in much of a position to do so). I also try to research and understand the other side before making a decision. If only the more tempered and more well rounded views made for good trade rag articles...
Posted by Matt Ingenthron on August 02, 2005 at 01:17 PM PDT #
I apologize if I sounded harsh in my posting. I too am tired of the Swing vs SWT debate and I don't mean to fuel it. There are pluses and minuses to both tools. In fact, you can do the same thing in either toolkit. I think that Sun has put a lot of effort into Swing and that is a very good thing. You could, however, ask the same question: What is the opportunity cost of developing Swing? For SWT, you need to make sure all your widgets are implemented with native peers on all platforms. Similarly, for Swing you have to make sure that your "Look and Feel" mimicks your native platform. With every new OS release, instead of Swing feeling native - it has to be tweaked and retweaked. Using native peers it just works. For example, things that don't work with Swing in Vista can be seen in this post: http://blogs.sun.com/roller/page/wangwj/20050729
So that's the big difference between an emulated widget set vs a native widget set. With emulated you'll necessarily lag behind in the look-and-feel department until programmers tweak the feel to match the latest version. Not to be one sided, there are a number of nice things that completely emulated widget set allows you to do (mentioned above -> opengl acceleration, full frame double buffering, etc) Also, AFIAK Swing is an extended java api: (javax.swing) so it's not considered a "core" part of Java. It's only available on the platforms for which it's implemented - same as SWT. Some JVM's (GNU Classpath) don't have a complete implementation of Swing, but can use SWT with no problems. Swing just happens to be bundled together with J2SE. For example, does Swing work on QNX? (no) Does Eclipse work on VMS? (no) Does Swing work on phones? (no) Does eSWT works on phones (yes)
But enough of this. I think I got my point across. Again would like to say that both toolkits have their merits, and both are actively being developed. Neither one is "better" than the other. I don't usually comment on blog entries - especially on these potentially religious issues, but I was in a chatty mood today ;-)
Posted by Eclipse Fan on August 02, 2005 at 06:03 PM PDT #