Start A New Journey With JavaFX 9
JavaFX is a software platform for creating desktop applications and rich internet applications (RIAs) that can run across various devices. JavaFx applications could run on any desktop that could run Java SE or on any mobile phone that could run Java ME. There are so many versions of JavaFx running in the market such as JavaFX 1.0, JavaFX 1.1, JavaFX 1.2, JavaFX 1.3, JavaFX 1.3.1, JavaFX 2.0, JavaFX 2.1, JavaFX 2.2, JavaFX 8. The latest one is JavaFX 9. This article is specifically focused on the new features of JavaFX 9.
The highlights of JavaFX updates in JDK 9 are the Skin / CSS APIs Jigsaw modularization.
- 1.Modularization (Project Jigsaw)
- The first thing is that JavaFX is now broken up into seven modules:
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.
- 2.Improved Encapsulation
Java FX 9 brings severe 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.
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.
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, javafx.scene.control.skin was released to address this need.
56 new skin API classes and 11 CSS classes were added in JDK 9.
In JDK 9, Java FX added High-DPI support and improvements for Linux and Windows.
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.
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.
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.
These all features would be very much useful for JavaFX Developers in developing rich applications.