What Is JavaFX?
JavaFX is designed to provide Java developers with a new lightweight, high performance graphics platform. The intention is for new applications to use JavaFX rather than Swing to build the application's graphical user interface (GUI). This does not mean that Swing is obsolete. The vast number of applications in use that have been built using Swing mean that it will be part of the Java API for a long time yet. Especially as these applications can incorporate JavaFX functionality because the two graphical APIs run side by side seamlessly.
JavaFX can be used to create graphical user interfaces for any platform (e.g., desktop, web, mobile, etc..).
JavaFX History - Before v2.0
Originally the focus for the JavaFX platform was mainly for rich internet applications (RIAs). There was a JavaFX scripting language intended to make the creation of a web-based interface easier. The JavaFX versions reflecting this architecture were:
- v1.0 released December 2008
- v1.1 released February 2009
- v1.2 released June 2009
- v1.3 released April 2010
The JavaFX 1.x versions have an End of Life date of December 20, 2012. After that these version will no longer be available and it's reccomended any JavaFX 1.x production applications should be migrated over to JavaFX 2.0.
JavaFX Version 2.0
In October 2011, JavaFX 2.0 was released. This signaled the end of the JavaFX scripting language and the move of the JavaFX functionality into a Java API. This meant that Java developers did not need to learn a new graphics language and instead be comfortable creating JavaFX application using normal Java syntax. The JavaFX API contains everything you would expect from a graphics platform - UI controls, animations, effects, etc..
The main difference for developers switching from Swing to JavaFX will be getting used to how the graphical components are laid out and the new terminology. A user interface is still built using a series of layers that are contained within a scene graph. The scene graph is displayed upon a top-level container called a stage.
Other notable features with JavaFX 2.0 are:
- a new graphics engine - Prism, a hardware accelerated pipeline, is coupled with Glass, as new windowing tookit, to produce high quality graphics for JavaFX applications.
- a new declarative markup language called FXML. It is based on XML and enables developers to define a user interface for a JavaFX application.
- a new media engine for playing web multimedia content.
- a browser plug-in for loading JavaFX applets using Prism.
- a web component for embedding web pages within a JavaFX application.
- a doclet for generating JavaFX API documentation using Javadoc
There are also a number of sample Java applications that come with the SDK to show developers how to build different kinds of JavaFX applications.
For windows users, the JavaFX SDK comes part of the Java SE JDK since Java 7 update 2. Likewise the JavaFX runtime now comes Java SE JRE.
As of January 2012, there is a JavaFX 2.1 developer preview available to download for Linux and Mac OS X users.
If you are interested in seeing what it takes to build a simple JavaFX application have a look at Coding a Simple Graphical User Interface - Part III and the Example JavaFX code for Building a Simple GUI Application.