Why should I use JavaFX?

Shane Khant Soe Moe
2 min readMar 10, 2018

I have seen a lot of questions asking about why we should use JavaFX when we have Swing as Graphical User Interface (GUI) and media package (sound and video players) for java.

Well, in my opinion, the purpose of JavaFX seems to get rid of obsolete and uncool Java Swing GUI, and become the future GUI for Java-based applications. I believe that’s what oracle is going for:

I’m an entry-level software engineer who often uses JavaFX for GUI in my Java programs, and I want to share why we should use JavaFX by describing some differences between Swing and JavaFX.

Here’s why:

  1. JavaFX can be styled with CSS, whereas Swing cannot be. If we want to style Swing GUIs with CSS, we will need to use third party source like flying-saucer. Being able to implement CSS is a unique functionality of JavaFX, and that alone lets programmers easily and swiftly create cool designs in applications.
  2. JavaFX makes programmers’ life easy by offering “JavaFX scene builder” with which programmers can create GUI controls like buttons via drag and drop.
  3. JavaFX supports Java Lambda expressions in action-triggering events unlike Swing. Using Lambda expressions, JavaFX promotes code readability and just needs fewer lines of code than Swing.
  4. JavaFX has built-in data visualization such as 2D charts
  5. JavaFX 3D API is an awesome API to create 3D objects in creating games or customizing charts in JavaFX.
  6. JavaFX is a good alternative GUI for Android and iOS, meaning JavaFX is portable now. Though JavaFX is not as good as native GUIs, it still performs smoothly on both Android and iOS platforms by using Gluon.

--

--

Shane Khant Soe Moe

Software engineer @ OPIS by IHS Markit (2020 — present)