JavaFX
JavaFX is a software platform for creating and delivering desktop applications, as well as rich Internet applications that can run across a wide variety of devices. JavaFX is intended to replace Swing as the standard GUI library for Java SE, but both will be included for the foreseeable future. JavaFX has support for desktop computers and web browsers on Microsoft Windows, Linux, and macOS.
Before version 2.0 of JavaFX, developers used a statically typed, declarative language called JavaFX Script to build JavaFX applications. Because JavaFX Script was compiled to Java bytecode, programmers could also use Java code instead. JavaFX applications could run on any desktop that could run Java SE or on any mobile phone that could run Java ME.
and later is implemented as a "native" Java library, and applications using JavaFX are written in "native" Java code. JavaFX Script has been scrapped by Oracle, but development is being continued in the Visage project. JavaFX 2.x does not support the Solaris operating system or mobile phones; however, Oracle plans to integrate JavaFX to Java SE Embedded 8, and Java FX for ARM processors is in developer preview phase.
On desktops, JavaFX supports Windows Vista, Windows 7, Windows 8, Windows 10, macOS and Linux operating systems. Beginning with JavaFX 1.2, Oracle has released beta versions for OpenSolaris. On mobile, JavaFX Mobile 1.x is capable of running on multiple mobile operating systems, including Symbian OS, Windows Mobile, and proprietary real-time operating systems.
Open-source JavaFXPorts works for iOS and Android and embedded ; and the related commercial software created under the name "Gluon" supports the same mobile platforms with additional features plus desktop. This allows a single source code base to create applications for the desktop, iOS, and Android devices.
With the release of JDK 11 in 2018, Oracle has made JavaFX part of the OpenJDK under the OpenJFX project, in order to increase the pace of its development. Oracle support for JavaFX is also available, for the current long-term version, through March 2025.
Technical highlights
JavaFX 1.1 was based on the concept of a "common profile" that is intended to span across all devices supported by JavaFX. This approach makes it possible for developers to use a common programming model while building an application targeted for both desktop and mobile devices and to share much of the code, graphics assets and content between desktop and mobile versions. To address the need for tuning applications on a specific class of devices, the JavaFX 1.1 platform includes APIs that are desktop or mobile-specific. For example, the JavaFX Desktop profile includes Swing and advanced visual effects.For the end user, the "Drag-to-Install" feature enables them to drag a JavaFX widget - an application residing in a website - and drop it onto their desktop. The application will not lose its state or context even after the browser is closed. An application can also be re-launched by clicking on a shortcut that gets created automatically on the user's desktop.
This behavior is enabled out-of-the-box by the Java applet mechanism since the Java 6u10 update, and is leveraged by JavaFX from the underlying Java layer.
Sun touts "Drag-to-Install" as opening up of a new distribution model and allowing developers to "break away from the browser".
JavaFX 1.x included a set of plug-ins for Adobe Photoshop and Illustrator that enable advanced graphics to be integrated directly into JavaFX applications. The plug-ins generate JavaFX Script code that preserves the layers and structure of the graphics. Developers can then add animation or effects to the static graphics imported. There is also an SVG graphics converter tool that allows for importing graphics and previewing assets after the conversion to JavaFX format.
Web Component
WebView, the embedded browser component, supports the following HTML5 features:- Canvas
- Media playback
- Form controls
- Editable content
- History maintenance
- Support for the
and - Support for the and
tags
- DOM
- MathML
- SVG
- CSS
- JavaScript
- Support for domain names written in national languages
Design highlights
JavaFX platform components
JavaFX 2.x platform includes the following components:- The JavaFX SDK: runtime tools. Graphics, media web services, and rich text libraries. Java FX 1.x also included JavaFX compiler, which is now obsolete as JavaFX user code is written in Java.
- NetBeans IDE for JavaFX: NetBeans with drag-and-drop palette to add objects with transformations, effects and animations plus a set of samples and best practices. For JavaFX 2 support you need at least NetBeans 7.1.1. For Eclipse users there is a community-supported plugin hosted on eclipse.
- JavaFX scene builder: This was introduced for Java FX 2.1 and later. A user interface is created by dragging and dropping controls from a palette. This information is saved as an FXML file, a special XML format.
- Tools and plugins for creative tools : Plugins for Adobe Photoshop and Adobe Illustrator that can export graphics assets to JavaFX Script code, tools to convert SVG graphics into JavaFX Script code and preview assets converted to JavaFX from other tools
JavaFX Mobile
An independent application platform built on Java, JavaFX Mobile is capable of running on multiple mobile operating systems, including Android, Windows Mobile, and proprietary real-time operating systems.
JavaFX Mobile was publicly available as part of the JavaFX 1.1 release announced by Sun Microsystems on February 12, 2009.
Sun planned to enable out-of-the-box support of JavaFX on the devices by working with handset manufacturers and mobile operators to preload the JavaFX Mobile runtime on the handsets. JavaFX Mobile running on an Android was demonstrated at JavaOne 2008 and selected partnerships were announced at the JavaFX Mobile launch in February, 2009.
History
JavaFX Script, the scripting component of JavaFX, began life as a project by Chris Oliver called F3.Sun Microsystems first announced JavaFX at the JavaOne Worldwide Java Developer conference on May 2007.
In May 2008 Sun Microsystems announced plans to deliver JavaFX for the browser and desktop by the third quarter of 2008, and JavaFX for mobile devices in the second quarter of 2009. Sun also announced a multi-year agreement with On2 Technologies to bring comprehensive video capabilities to the JavaFX product family using the company's TrueMotion Video codec. Since end of July 2008, developers could download a preview of the JavaFX SDK for Windows and Macintosh, as well as the JavaFX plugin for NetBeans 6.1.
Major releases since JavaFX 1.1 have a release name based on a street or neighborhood in San Francisco. Update releases typically do not have a release name.
Oracle announced their intention to stop shipping JavaFX with JDK 11 and later, and it's no longer bundled with the latest version.
JavaFX 1.0
On December 4, 2008 Sun released JavaFX 1.0.2.JavaFX 1.1
JavaFX for mobile development was finally made available as part of the JavaFX 1.1 release announced officially on February 12, 2009.JavaFX 1.2
JavaFX 1.2 was released at JavaOne on June 2, 2009. This release introduced:- Beta support for Linux and Solaris
- Built-in controls and layouts
- Skinnable CSS controls
- Built-in chart widgets
- JavaFX I/O management, masking differences between desktop and mobile devices
- Speed improvements
- Windows Mobile Runtime with Sun Java Wireless Client
JavaFX 1.3
- Performance improvements
- Support of additional platforms
- Improved support for user interface controls
JavaFX 1.3.1
- Quick startup time of JavaFX application
- Custom progress bar for application startup
JavaFX 2.0
- A new set of Java APIs opening JavaFX capabilities to all Java developers, without the need for them to learn a new scripting language. Java FX Script support was dropped permanently.
- Support for high performance lazy binding, binding expressions, bound sequence expressions, and partial bind re-evaluation.
- Dropping support for JavaFX Mobile.
- Oracle announcing its intent to open-source JavaFX.
- JavaFX runtime turning to be platform-specific, utilizing system capabilities, as video codec available on the system; instead of implementing only one cross-platform runtime as with JavaFX 1.x.
On May 26, 2011, Oracle released the JavaFX 2.0 Beta. The beta release was only made available for 32 and 64 bit versions of Microsoft Windows XP, Windows Vista and Windows 7. An Early Access version for Mac OS X was also available for members of the JavaFX Partner Program at the time, while Linux support was planned for a future release of JavaFX. JavaFX 2.0 was released with only Windows support. Mac OS X support was added with JavaFX 2.1. Linux support was added with JavaFX 2.2.
JavaFX 2.0 makes use of a new declarative XML language called FXML.
JavaFX 2.1
On April 27, 2012, Oracle released version 2.1 of JavaFX, which includes the following main features:- First official version for OS X
- H.264/MPEG-4 AVC and Advanced Audio Coding support
- CoolType text
- UI enhancements including combo box controls, charts, and menu bars
- Webview component now allows JavaScript to make calls to Java methods
JavaFX 2.2
- Linux support
- Canvas
- New controls: Color Picker, Pagination
- HTTP Live Streaming support
- Touch events and gestures
- Image manipulation API
- Native Packaging
As of Oracle Java SE 7 update 6 and Java FX 2.2, JavaFX is bundled to be installed with Oracle Java SE platform.
JavaFX 8
JavaFX is now part of the JRE/JDK for Java 8 and has the same numbering, i.e., JavaFX 8.JavaFX 8 adds several new features, including:
- Support for 3D graphics
- Sensor support
- MathML support, with JavaFX 8 Update 192
- Printing and rich text support
- Generic dialog templates via inclusion of ControlsFX to replace JOptionPane as of JavaFX 8u40
JavaFX 9
- JEP 253: Prepare JavaFX UI Controls and CSS APIs for Modularization
JavaFX 11
- JavaFX 11.0.2 is the latest public release of JavaFX 11.
- JavaFX 11.0.3 is the latest release of JavaFX 11 for those with a long-term support contract.
- MathML support, with JavaFX 11
- FX Robot API
JavaFX 12
- JavaFX 12.0.1.
JavaFX 13
JavaFX 14
JavaFX 14 is the latest JavaFX release available now.Future work
Oracle also announced in November 2012 the open sourcing of Decora, a DSL Shader language for JavaFX allowing to generate Shaders for OpenGL and Direct3D.Oracle wrote in its Client Support Roadmap that JavaFX new fixes will continue to be supported on Java SE 8 through March 2025. Previously, Oracle announced that they are "working with interested third parties to make it easier to build and maintain JavaFX as a separately distributable open-source module." JavaFX will continue to be supported in the future by the company Gluon as a downloadable module in addition to the JDK.
JavaFX application example
Example code
The following is a rather simple JavaFX-based program. It displays a window containing a button.package javafxtuts;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class JavaFxTuts extends Application
Platforms
As of March 2014 JavaFX is deployed on Microsoft Windows, OS X, and Linux. Oracle has an internal port of JavaFX on iOS and Android. Support for ARM is available starting with JavaFX 8 On February 11, 2013, Richard Bair, chief architect of the Client Java Platform at Oracle, announced that Oracle would open-source the iOS and Android implementations of its JavaFX platform in the next two months.Starting with version 8u33 of JDK for ARM, support for JavaFX Embedded has been removed.
Support will continue for x86-based architectures.
A commercial port of JavaFX for Android and iOS has been created under the name "Gluon".
License
There are various licenses for the modules that compose the JavaFX runtime:- Parts of the core JavaFX runtime are still proprietary software and its code has not yet been released to the public, however developers and executives behind the technology are moving toward a full opening of the code,
- The JavaFX compiler and an older version of the 2D Scene graph are released under a GPL v2 license,
- The NetBeans plugin for JavaFX is dual licensed under GPL v2 and CDDL.
At JavaOne 2011, Oracle Corporation announced that JavaFX 2.0 would become open-source. Since December 2011, Oracle began to open-source the JavaFX code under the GPL+linking exception.
In December 2012, new portions of the JavaFX source code were open-sourced by Oracle:
- the animations and timelines classes
- the event delivery mechanism and other various core classes
- the render tree interface, and the implementation of this interface
- the geometry and shapes implementation
- the java part of the rendering engine used in the rendering pipeline
- the logging support