Java Desktop Application: Swt VS. Swing

Java Desktop application: SWT vs. Swing

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.

Compare SWT with SWING

See this web sites:

  1. SWT, AWT and Swing
  2. Swing vs SWT
  3. Swing vs SWT(2nd)

Very nice webpages with example source code:

  1. SWT
  2. SWT 2d-Graphics

Swing vs JavaFx for desktop applications

What will be cleaner and easier to maintain?

All things being equal, probably JavaFX - the API is much more consistent across components. However, this depends much more on how the code is written rather than what library is used to write it.

And what will be faster to build from scratch?

Highly dependent on what you're building. Swing has more components around for it (3rd party as well as built in) and not all of them have made their way to the newer JavaFX platform yet, so there may be a certain amount of re-inventing the wheel if you need something a bit custom. On the other hand, if you want to do transitions / animations / video stuff then this is orders of magnitude easier in FX.

One other thing to bear in mind is (perhaps) look and feel. If you absolutely must have the default system look and feel, then JavaFX (at present) can't provide this. Not a big must have for me (I prefer the default FX look anyway) but I'm aware some policies mandate a restriction to system styles.

Personally, I see JavaFX as the "up and coming" UI library that's not quite there yet (but more than usable), and Swing as the borderline-legacy UI library that's fully featured and supported for the moment, but probably won't be so much in the years to come (and therefore chances are FX will overtake it at some point.)

SWT or Swing for Plugin Project

One advantage of doing it in Swing is that you don't have to supply any other libraries, because Swing is part of JRE. With SWT you have to do it and you have to have separate dlls for specific platforms.
UPDATE:
Since you mentioned that you have to create Eclipse plugin, I think you have a clear choice here - SWT. It is what Eclipse is based on.

Java desktop application frameworks vs. JavaFX

There are plenty of them looks like your research has not been very thorough

  • http://efxclipse.org/ - in fact it leverages the same core stuff than the Eclipse 4 IDE / RCP 4 but replaces the SWT layer with JavaFX
  • http://www.jrebirth.org/
  • http://www.drombler.org/drombler-fx/
  • http://jacpfx.org/

As I'm the author of e(fx)clipse I'm biased but I know first hand that it is used on (big) commercial projects

GUI for a Java stand alone app. Should I use SWT or GWT?

You appear to be confused. GWT is strictly for developing web apps. You cannot use it to build a regular desktop GUI.

If you want to write a regular Java GUI, your choices are

  • SWT
  • Swing
  • JavaFX

See e.g. these questions for a comparison:

Java Desktop application: SWT vs. Swing

JavaFX or Swing?.



Related Topics



Leave a reply



Submit