Java Desktop application: SWT vs. Swing [closed]
I'm a web developer at day and thinking about building my first real desktop application. The idea is to build a tool that automates a very repetitive task in a web application where no API is available.
I know I want to use Java. I used it before for web stuff, know the syntax pretty well and want the application to be cross plattform as easy as possible.
Where I'm not so sure is if I should use SWT or Swing. As my main audience uses Windows, I want to look it as native as possible there. Linux and Mac should work, but the looks are not so important here.
So what are the arguments for and against each UI Framework, Swing or SWT?
Thanks.
PS: I develop on Windows using Eclipse. But was thinking about playing with Netbeans.
Solution 1:
Pros Swing:
- part of java library, no need for additional native libraries
- works the same way on all platforms
- Integrated GUI Editor in Netbeans and Eclipse
- good online tutorials by Sun/Oracle
- Supported by official java extensions (like java OpenGL)
Cons Swing:
- Native look and feel may behave different from the real native system.
- heavy components (native/awt) hide swing components, not a problem most of the time as as use of heavy components is rather rare
Pros SWT:
- uses native elements when possible, so always native behavior
- supported by eclipse, gui editor VEP (VEP also supports Swing and AWT)
- large number of examples online
- has an integrated awt/swt bridge to allow use of awt and swing components
Cons SWT:
- requires native libraries for each supported system
- may not support every behavior on all systems because of native resources used (hint options)
- managing native resources, while native components will often be disposed with their parent other resources such as Fonts have to be manually released or registered as dispose listener to a component for automatic release.
Solution 2:
An important thing to consider is that some users and some resellers (Dell) install a 64 bit VM on their 64 bit Windows, and you can't use the same SWT library on 32 bit and 64 bit VMs.
This means you will need to distribute and test different packages depending on whether users have 32-bit or a 64-bit Java VM. See this problem with Azureus, for instance, but you also have it with Eclipse, where as of today the builds on the front download page do not run on a 64 bit VM.
Solution 3:
pro swing:
- The biggest advantage of swing IMHO is that you do not need to ship the libraries with you application (which avoids dozen of MB(!)).
- Native look and feel is much better for swing than in the early years
- performance is comparable to swt (swing is not slow!)
- NetBeans offers Matisse as a comfortable component builder.
- The integration of Swing components within JavaFX is easier.
But at the bottom line I wouldn't suggest to use 'pure' swing or swt ;-) There are several application frameworks for swing/swt out. Look here. The biggest players are netbeans (swing) and eclipse (swt). Another nice framework could be griffon and a nice 'set of components' is pivot (swing). Griffon is very interesting because it integrates a lot of libraries and not only swing; also pivot, swt, etc