JavaFX 2 vs Swing for a pure Windows desktop app

17,496

Solution 1

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.

Status update 15 september 2021:

  • The JavaFX community is still going strong. OpenJFX is still there and has a flashier home.
  • Companies like Gluon (I'm not affiliated with them) offer commercial support LTS releases for OpenJFX.
  • There is GraalVM support for JavaFX allowing you to make JavaFX applications and distribute them as native binaries (ie. no JVM needed).
  • There are excellent opensource JavaFX component libraries available like TilesFX.

Solution 2

Both are good options:

  • If you want a rich, graphically enhanced application, the features of JavaFX 2.0 may be very appealing. It is designed to give you a lot of creative control over your user experience and visuals. Just be sure that it is supported on your target platforms....
  • If you want a standard desktop application that runs on as many platforms as possible, then Swing is probably a safer choice (since Swing is guaranteed to be available as part of all modern Java distributions). It also has the advantage of more mature 3rd party libraries.

Neither is likely to replace the other: they have slightly different target uses and will probably co-exist for many years to come.

Share:
17,496

Related videos on Youtube

DD.
Author by

DD.

Updated on June 20, 2022

Comments

  • DD.
    DD. almost 2 years

    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?

    • assylias
      assylias about 12 years
    • jewelsea
      jewelsea about 12 years
      To get a good answer, you really need to describe your intended app to some detail, otherwise the question is too open-ended.
  • Andrew Thompson
    Andrew Thompson over 11 years
    "As stated JavaFX is going to deprecated" As stated by who? When? I would not believe that unless you can supply a link to a page at Oracle that supports the statement. The claim is hard to believe since a) AWT is not deprecated, & b) by your own words, Swing components can be used in Java FX.
  • The Unfun Cat
    The Unfun Cat over 11 years
    @Thompson: I'd like to know that too. (Perhaps he is thinking of: oracle.com/technetwork/java/javafx/overview/faq-1446554.html‌​#6 )
  • Vineet
    Vineet over 11 years
    @Thompson, I think he got an extra 'd' in there. I think he meant to say that 'JavaFX is going to deprecate Swing'. See here: oracle.com/technetwork/java/javafx/overview/faq-1446554.html‌​#6
  • Jasper Siepkes
    Jasper Siepkes over 11 years
    @Vineet Indeed the extra 'd' wasn't supposed to be in that sentence :-). JavaFX is not going to be deprecated anytime soon (as far as I know). I removed the extra 'd'. Funny how one letter can change the entire meaning of a sentence...

Related