Adrian D. Finlay
Sep 30, 2017 · 6 min read
JavaFX Logo [2]

JavaFX is a 3rd Generation Java GUI platform (after AWT, Swing) for the development of Desktop and Rich Internet Applications. As of JDK8, It is a part of Java SE. JavaFX provides resources to build thick client applications that interact with Java SE, ME, and EE. JavaFX supports Windows Vista — Current, Mac OSX — macOS, and various Linux operating systems. There are also ports for various mobile platforms. The current version of Java FX mirrors the JDK numbering as Java FX 9. An overview of the updates to the Java FX Platform of JDK release 9 will be the focus of this article.

Not Caught up to Java 9? Learn more below:

JavaFX happens to be one of my favourite technologies :) I love Desktop Apps. I love Java. And I also like what Danny Coward & the Java Client Group did with JavaFX; It is a refreshing breath in the right direction, learning the lessons from it’s predecessors: AWT & Swing.

Because of the heavy focus on Project Jigsaw (Modularity), JDK 9 included few upgrades to java language features as well as JavaFX APIs. The highlights of Java FX updates in JDK 9 are the Skin/CSS APIs and Jigsaw modularization.

JavaFX License

JavaFX is dual licensed under the GPL v2 with Classpath Exception and Oracle Binary Code License for the Java SE Platform[5] with a commitment to go fully open source in the foreseeable future[3]. openJFX is the community effort behind JavaFX.

A Brief Java FX Primer — Hello World

While this article will not examine the JavaFX APIs in depth, if you’ve never seen a JavaFX Application before, below are some screenshots of a Hello World application.

Some screenshots of the execution. The background toggles on the button event’s (clicking off the Hello JavaFX World! button) firing.

Want the source? Grab it here.

So What’s New?

#1 — Modularization (Project Jigsaw)

The first thing to notice is that JavaFX is now broken up into seven modules [7]:

  • Base APIs for JavaFX UI Toolkit — javafx.base
  • JavaFX APIs for UI Controls — javafx.controls
  • JavaFX APIs for FXML — javafx.fxml
  • JavaFX APIs for various Graphics Tools— javafx.graphics
  • JavaFX APIs for Multimedia — javafx.media
  • JavaFX APIs for Swing-JavaFX Interoperability — javafx.swing
  • JavaFX APIs for WebView Functionality — javafx.web

The advantages of modularity include improved scalability, ability to test software components independently without breaking code other code or having to recompile an entire system, among others.

The javapackager can now give you an application with only the modules you need. All modular JavaFX applications require the javafx.base & javafx.graphics modules. All modular Java FX UI Applications require the javafx.controls module. Packages may only belong to one module. Modular applications will need to list dependencies in module-info.java.

JEP 253 & JEP 200 were the community efforts towards modularizing the JDK and the JavaFX UI Controls & CSS APIs. They came about by the overall push towards a modular JDK and was incentivized by the advantage of providing public availability for functionality found only in internal APIs.

#2 — Improved Encapsulation

Java FX 9 brings stricter encapsulation on Java FX API internals. This provides some enforcement for better compliance of avoiding the use of the Java FX internal APIs. Only public types of explicitly exported packages are available[3]. While there is a work-around, I won’t mention it, because you should resist the urge to use it ;). Think within the API.

The APIs: com.sun* packages and impl__ methods have been either deprecated, replaced, or made public, now that JDK 9 modularity hides non-public packages. Node builders should be avoided. Class.getResource should be used instead of ClassLoader.getResource(). Classpath relative URL strings should be avoided.

#3 — New API

Commonly, developers were dipping into com.sun.javafx.scene.control.skin to develop Java FX skins. This means that developers were relying on private API. Often enough, the grounds for dipping into JavaFX internal APIs could be argued by the need for functionality. In JDK 9 a new API A new API, javafx.scene.control.skin was released to address this need.

A concomitant consequence of the push towards JDK modularity led to the opportunity to provide public implementation for a lot of very useful private API, hence JEP 253. Beginning in June of 2015, members of the Java Client Group and openJFX began polling the community for the most useful private API. They found the following API to be the most wanting of examination: UI Control Skins, CSS APIs, Toolkit / Platform APIs, Robot, Performance Tracker[3]. All but the Robot and Performance Tracker APIs were addressed in JDK 9.

56 new skin API classes and 11 CSS classes were added in JDK 9[6].

#4 — Graphical Improvements

In JDK 9, Java FX added High-DPI support and improvements for Linux and Windows[3].

GTK3 Linux Support —
At present, Ubuntu 16.04 LTS & SWT 4.6 and other platforms have migrated to GTK3. JDK 9 may outlive GTK 2 support. To ensure continuing functionality, JDK 9 added GTK3 support. The community effort behind this was JEP 283.

#5 — Updates to GStreamer, WebKit

The GStreamer platform version was upgraded to the latest version and WebKit was updated with performance enhancements and bug fixes [3].

#6 — Miscellaneous API Enhancements and Bug Fixes

At least 102 small enhancements in the Tooltip, ComboxBox, Spinner, Node, Font, Collections, & FXPermission APIs were added and more than 756 bug fixes have been made[3].

Where to learn JavaFX?

Pro JavaFX 9

In my opinion, this is the defacto reference text on JavaFX 9. Written by the experts, this is the most expansive text on JavaFX 9 to date and should be familiar reading for every serious JavaFX developer.

JavaFX 9 by Example

Another stellar text from Apress press. This is an excellent primer for JavaFX newbies that want to get a solid, rigorous introduction to the platform. Experts can learn from this text as well. I learned about the JavaFX printing API from this text.

Looney Tunes Ending [8]

Works Cited

[1] — https://en.wikipedia.org/wiki/JavaFX

[2] — https://blog.idrsolutions.com/2013/09/java-articles-index-understanding-the-world-of-java-and-java-fx/

[3] — JavaOne Talk — JavaFX: New & Noteworthy, Kevin Rushforth & Jonathan Giles, Java Client Group, September 2016

[4] — http://www.oracle.com/technetwork/java/javafx/overview/faq-1446554.html

[5] — Binary Code License Agreement for the Java SE Platform Products and JavaFX

[6] —Oracle Official Java FX 9 API Documentation

[7] — JEP 253: Prepare JavaFX UI Controls & CSS APIs for Modularization

[8] — https://www.youtube.com/watch?v=0FHEeG_uq5Y

The Java Report

A curation of contemporary content on all things Java, JavaFX, JavaEE, and JVM technologies.

Adrian D. Finlay

Written by

@thewiprogrammer. Lover of learning, programming. Tech writer, Java aficionado. Proud mango, fishing, NBA addict! & more. Network w/ me @ bit.ly/AdfNtWk

The Java Report

A curation of contemporary content on all things Java, JavaFX, JavaEE, and JVM technologies.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade