ArcObjects Java, Swing/AWT.....but what about SWT?

I like Swing a lot. Am I a rationally-thinking programmer? Ha! No. But I like Swing for a number of my own reasons. Let me share:

1. Swing is guaranteed to run on any JVM. No special installations or special JVMs.

2. Swing is rich with so many components and events, richer than AWT. Uh, do I understand ALL of the models and events and patterns here? No.

3. The tooling for Swing is terrific. Eclipse and Netbeans both have great tools for Swing development. I like tools. I need tools.

4. Swing is "top-to-bottom" and "bottom-to-top": I don't need to create a JPanel or JFrame before creating a JButton, or visa versa.

I do understand that there are drawbacks to using Swing as well. For starters:

1. Swing applications with heavy UIs may run a bit slow on certain platforms.

2. Swing look and feel may not always be consistent across all platforms

3. more....

SWT (The Standard Widget Toolkit) is a different beast when it comes to building UI-rich cross platform applications for the desktop. It is also a strong platform for doing what Swing and AWT do as windowing toolkits, but tries to fill the voids that Swing and AWT leave us with.

1. Swing and AWT do not render "native" widget components. SWT does use native widgets for a natural "look and feel"

2. Because Swing/AWT to not use the native widgets found on different platforms, the abstraction can cost you in performance. SWT is more native, and can perform better, as it provides the thinest possible widget support, natively, for the widest range of platforms. But care must be take when developing for specific platforms.

There are many compelling reasons for organizations to choose the RCP/SWT/Eclipse platform for their application development and maintenence environments.

OK. We have some development choices and options out there for rich Java Desktop applications. Excellent. But here is some harsh reality: SWT and AWT do not mix. Can SWT and AWT widgets co-exist in the same application? Not very well, but it can be accomplished with a little help from the SWT-AWT bridge and some complex development approaches. Here is an interesting article that goes into depth on this topic, outlining the pitfals and angst that can be experienced in trying this.

So, what does this mean for ArcGIS Engine Java developers? The high-level UI developer components that ship with the Java SDK for ArcGIS Engine are based on AWT. Period. These components have never been successfully tested in SWT or "mixed" application development environments.

What I strongly encourage Java Engine developers to do is this: avoid trying to mix SWT with ArcGIS Engine application development at all costs. At the current release, this usage will not be supported. ESRI will look into this for possible consideration later on, but at the present time, please don't go there!

So, have fun on the Swing-set, and don't hurt yourself!

Published Monday, August 10, 2009 12:06 PM by eric906
Filed under: , , , ,

Comments

 

holsinger said:

Dear eric906,

Many developers and organizations have come to the realization that Swing just does not cut the mustard for commercial-quality apps in this day and age.  If you're developing in Swing, and it's for an internal-use-only project, fine - but SWT is really the only way to go for thick-client core java apps.  Period.  As far as the purported issues with the visual swing components and Unix, instead of coaxing developers away from this mix, we should be looking at the viable opportunities for the two technologies to mix.  Here, we have two options:  1. use a parent Swing window to embed two child windows, one hosting SWT and the other hosting the ArcGIS visual components (works great for us), or 2.  build-out of an SWT app with an embedded browser and using the web arcview components for map visualization in that browser...  With option #1, we can create very nifty map viewer controls with SWT (the out-of-the-box ArcGIS tools are very old-school), while controlling either the Swing map visualizer or the embedded browser fetches without issue, on all the major OS platforms.

Lastly, ESRI needs to jump on the SWT bandwagon ASAP AND start getting very serious about going native (instead of the need for JIntegra, etc.) with ALL their codebase.  In my humble opinion, ESRI is taking a major risk by dropping the ball on these issues with the likes of Google hot on their heels.

Don't fear SWT and other opportunities for product integration!

August 19, 2009 7:19 PM
 

eric906 said:

holsinger, this is fabulous feedback and input. I assure you that your thoughtful comments are greatly appreciated and taken very seriously. Thank you!

August 19, 2009 7:42 PM
 

frett27 said:

There are solutions, without mixing Jintegra Swing ActiveX exposed component and bridged to SWT in the same project in developping a GUI façade native to the plateform (SWT / Swing) and calling underlying ArcObjects / Business Objects.

The GUI map component is then simply implemented in the SWT framework and exchange images with the business object. you can also have a multithreaded behaviour in the map component.

We have experience on that solution too.

Regards.

August 20, 2009 7:01 AM
 

akarnstedt said:

Have fun on the Swing-set? Apart from the fact that it's nearly impossible to build a serious, productive, real-life application with Swing ..except those itsy-bitsy demo apps? ;)

Absolutely ageed with holsinger.

Btw we are developing an Eclipse RCP + ArcGIS Engine application since 2006. Yes there were some difficulties in the beginning - but so far nothing special to SWT. Those instability issues (particularly with the MapControl) are the same with Swing too. But after building some safeguards around the MapControl ..it works quite well.

I wrote about it at the forum:

http://forums.esri.com/Thread.asp?c=159&f=1706&t=198117

http://forums.esri.com/Thread.asp?c=159&f=1706&t=182602

Most of the problems we faced were the same with Swing (or even non-UI Java apps).. mostly issues with COM, Jintegra (cleaning objects etc.)

September 7, 2009 11:30 AM
 

eric906 said:

This is great to hear, akarnstedt! This information is encouraging to us as we try to plan for the next version of the software.

October 2, 2009 9:21 AM
Anonymous comments are disabled