views:

1625

answers:

7

which library better for faster java application swt or swing?

+2  A: 

According to wikipedia there is no clear winner (although you can edit that if you want). Inevitably, you can write benchmarks which will show either much faster that the other. Swing has more freedom to optimise on the Java side of things. SWT can allow more optimisations to occur within the windowing system.

Probably the bigger impact on performance is going to come from how your application behaves. Concentrate on getting your code clean (and do a little profiling when necessary).

Tom Hawtin - tackline
If this is the case, isn't Swing with winner since it is most capable of simulating the OS' theme?
Dimitry Z
Hell, no! SWT use native widgets, so you won't be able to behave better with Swing.
gizmo
I believe Swing has a better track record of keeping up with native widgets. It doesn't have to deal with fixing up native APIs. Where Swing fails in that regards is where you have pluggable engines, as on Linux.
Tom Hawtin - tackline
Ok, Tom, Wikipedia has been fixed at your behest. http://en.wikipedia.org/w/index.php?title=Swing_(Java))
shemnon
We'll see how long it lasts :)
shemnon
A: 
anjanb
+11  A: 

Several years ago Swing was slow so SWT was developed to make native API calls on systems. However, Swing performance has greatly improved and this is no longer the case. SWT is non-standard, while Swing is officially part of the Java spec. JavaFX will also be built on top of Swing. Unless your job requires writing Eclipse plugins, I would use Swing.

To see a really good app developed in Swing, take a look at Jetbrain's Java IDE. You can try it for 30 days.

http://www.jetbrains.com/idea/

Of course, Sun's Netbeans is a pure Swing app too and it's free.

http://www.netbeans.org/

+5  A: 

There is no slow swing application. Just poorly written. And this also apply for SWT. The most application make better responses because of eclipse core architecture. Before J6 there were several problems with gray windows during unresponsive periods but this is quite solved using fully double buffered approach in swing PLAFs. There is no better UI framework. There is only better written program which appropriately uses multi-threading to avoid unresponsiveness of UI. Personally I prefer Swing :)

Rastislav Komara
A: 

"faster" is subjective. Both can run fast, but it's easier to do something dumb to shoot yourself in the foot with Swing and make it feel slow.

That said though, I find Swing easier to work with at a code level than SWT.

madlep
+4  A: 

Today, both frameworks are fast. I suggest to check these criteria:

  1. SWT is more simple to use than Swing (especially if this is your first UI)
  2. Swing is older and you can find more components
  3. If you also use JFace, you will find many powerful widgets that work out of the box (where you would need a lot of additional configuration in Swing).
  4. Swing is available anywhere, SWT is not
  5. SWT is developed actively, you have the source and bugs are fixed quickly. Swing hasn't been touched in years, then there was suddenly a big update for Java 6. If you have an issue with Swing, well, Sun probably doesn't care.
  6. If you choose Swing, use a framework like SwingX. This will make your life much more simple.
Aaron Digulla
A: 

Technological decision towards the widget toolkit are pretty thin ice in my eyes. The amount of work you'd have to deliver when it comes to the application framework is considerable and much more decisive IMHO. I believe that the only argument that's in favor of SWT is it's native L&F. On the other hand most UI's tend towards non-native L&F nowadays. You clearly see this in the trend for Eclipse RCP apps to use the forms framework which paints custom gradients and sections and is no native interface in any way (the same applies to e4, the eclipse v4 elaboration project). To sum up, If RCP's an option in your project, I'd use Eclipse RCP (which is SWT). The completeness, vivacity and tempo this platform has is unbeatable. If RCP's not an option, Spring RCP looks pretty convincing to me (which is Swing based).