JavaFX 2 vs Swing for a pure Windows desktop app

DD. picture DD. · May 14, 2012 · Viewed 17.3k times · Source

I need to write a desktop app and its been a while since I started used Swing so will have a learning curve with either technology.

Are there any advantages in doing my app using JavaFX 2?

Answer

Jasper Siepkes picture Jasper Siepkes · May 14, 2012

4 Years back I was having the same question and came to the conclusion that I would be best of using Swing since a lot of third party libraries were still written for Swing in those days. Also 1.0 releases from Sun were usually a bit rough around the edges (I burned myself on JSF 1.0 and JPA 1.0 :-).

Today a lot of libraries have JavaFX counterparts or are available as JavaFX library. That said there are also a lot of libraries wich are still Swing exclusive. Also I've done some small things with JavaFX 2.0 and it seems really complete. I haven't bumped into any showstoppers.

You need to check how many external UI libraries you are going to use besides Swing / JavaFX (and which one). If the answer is not many or a lot have a Java FX alternative (or are simple to todo yourself) I would definitly go for JavaFX. Also you can still use Swing components in JavaFX.

As stated JavaFX is going to deprecate Swing in the future and Oracle seems committed on JavaFX (it also going to be opensourced). So I would highly recommend JavaFX.

Status update 13 april 2014:

  • JavaFX has been opensource for some time now: https://wiki.openjdk.java.net/display/OpenJFX/Main
  • The community is committed to JavaFX; JavaFX only libraries with no swing counterparts are starting to emerge.
  • Oracle has proven to be committed on JavaFX.

In case you weren't convinced 2 years back: JavaFX now definitely looks like the way to go. Though Swing will probably around for a long time it is currently in maintenance mode. It will take a lot of effort to port large applications (like IntellIJ or Netbeans) completely to JavaFX. And for those large applications such a large scale port is probably not worthwhile at the moment.