Wednesday, July 18, 2012


What Is JavaFX?

The JavaFX platform is the evolution of the Java client platform designed to enable application developers to easily create and deploy rich internet applications (RIAs) that behave consistently across multiple platforms. Built on Java technology, the JavaFX platform provides a rich set of graphics and media API with high-performance hardware-accelerated graphics and media engines that simplify development of data-driven enterprise client applications.
Investing in the JavaFX platform provides the following advantages to Java developers and companies that are part of the Java ecosystem:
  • Because the JavaFX platform is written in Java, Java developers can leverage their existing skills and tools to develop JavaFX applications.
  • Because Java is widely used, it is easy to find experienced Java developers who can quickly become productive building JavaFX applications.
  • By using a homogenous set of Java technologies for both the server and the client platforms, the JavaFX platform reduces the risk of investment by reducing the complexity of the business solutions.
  • Development costs are also reduced because of the aforementioned advantages.
  • The JavaFX platform provides developers with a development framework and runtime environment to create enterprise and business applications that run across multiple platforms that support Java.
See the JavaFX Architecture and Framework document to learn about the JavaFX platform's architecture and key concepts.

A Brief History of JavaFX

At the JavaOne 2007 conference, Sun Microsystems introduced the JavaFX platform to help content developers and application developers to create content-rich applications for mobile devices, desktops, televisions, and other consumer devices. The initial offering consisted of the JavaFX Mobile platform and the JavaFX Script language. Multiple public releases were delivered after the initial announcement; the 1.3 version was released on April 22, 2010.
After Oracle's acquisition of Sun Microsystems, Oracle announced during the JavaOne 2010 conference that support for the JavaFX Script language would be discontinued. However, it was also announced that the JavaFX Script APIs will be ported to Java and would be released as part of the JavaFX 2 product. This announcement meant that the JavaFX capabilities will become available to all Java developers, without the need for them to learn a new scripting language. With this announcement, Oracle has committed to making JavaFX the premier environment for rich client applications.

What's New in JavaFX 2?

The main focus areas for the JavaFX 2 release include the following features, many of which are also described in the JavaFX Architecture and Framework document:
  • Java APIs for JavaFX that provide all the familiar language features (such as generics, annotations, and multithreading) that Java developers are accustomed to using. The APIs are designed to be friendly to alternative JVM languages, such as JRuby and Scala. Because the JavaFX capabilities are available through Java APIs, you can continue to use your favorite Java developer tools (such as IDEs, code refactoring, debuggers, and profilers) to develop JavaFX applications.
  • A new graphics engine to handle modern graphics processing units (GPUs). The basis of this new engine is a hardware accelerated graphics pipeline, called Prism, that is coupled with a new windowing toolkit, called Glass. This graphics engine provides the foundation for current and future advancements for making rich graphics simple, smooth, and fast.
  • FXML, a new declarative markup language that is XML-based and is used for defining the user interface in a JavaFX application. It is not a compiled language and, hence, does not require you to recompile the code every time you make a change to the layout.
  • A new media engine that supports playback of the web multimedia content. It provides a stable, low latency media framework that is based on the GStreamer multimedia framework.
  • A web component that gives the capability of embedding web pages within a JavaFX application using the WebKit HTML rendering technology. Hardware accelerated rendering is made available using Prism.
  • A refreshed browser plug-In for JavaFX 2 that allows the loading of JavaFX applets based on Prism.
  • A wide variety of built-in UI controls, which include Charts, Tables, Menus, and Panes. Additionally, an API is provided to allow third parties to contribute UI controls that the user community can use.
  • Sample applications that showcase the different features of the JavaFX 2 technology, along with a large number of code samples and snippets.
  • An updated doclet used with the Javadoc tool to generate JavaFX API documentation in HTML format. Detailed information on how to use this updated doclet can be found inUsing a Doclet with JavaFX.

What Can I Build with JavaFX?

Table 1 shows thumbnail images of some of the sample JavaFX applications that are included with the JavaFX 2 release. Click each thumbnail to view a larger image of the application.
To run these and additional sample applications, go tohttp://www.oracle.com/technetwork/java/javafx/downloads/index.html. Download the zip file that contains the JavaFX Samples and extract the files. The javafx-samples-2.1.x\ directory is created and contains the files for the available samples. You can run a sample by double clicking one of its executable files. For example, to run the Ensemble sample application, double-click the Ensemble.jar file. NetBeans projects for the samples are in the javafx-samples-2.1.x\src directory. Refer to the JavaFX Release Documentation page for the appropriate System Requirements document that lists the supported version of NetBeans IDE that you need to run these sample projects.
Table 1 Sample JavaFX Applications
Sample ApplicationDescription
Thumbnail version of the Ensemble application snapshot.
JavaFX Ensemble
Ensemble provides a gallery of applications that demonstrate various JavaFX features, such as animation, charts, and controls. You can view the running sample, read a description, copy the source code, and follow links to the relevant API documentation.
Thumbnail version of the Sales Dashboard application snapshot
Sales Dashboard (DataApp)
A client-server application for a fictional global automobile company called Henley Automobiles. Automobile sales are simulated on an EJB server using JavaDB, and the data is available via Derby and a RESTful web service. The client demonstrates a variety of data presentations, using a mix of FXML and JavaFX.
Thumbnail version of the SwingInterop sample application.
SwingInterop Sample
This Swing application shows how Swing and JavaFX can be combined. It uses JavaFX components to implement a chart and a table in one tab, and it shows a simple browser implemented by JavaFX in another tab.
Source code for each sample is in the javafx-samples-2.1.x\src directory. To view the source code, go to the javafx-samples-2.1.x\src\ directory, where is the name of the application in which you are interested. Each of the sample source directories is a NetBeans project.

How Do I Create JavaFX Applications?

Because JavaFX applications are written in the Java language, you can use your favorite editor or any integrated development environment (IDE) that supports the Java language, such as NetBeans, Eclipse, Oracle JDeveloper, or IntelliJ IDEA, to develop JavaFX applications. Use the following steps to get started creating JavaFX applications:
  1. Go to http://www.oracle.com/technetwork/java/javafx/downloads/index.html/ to download the JavaFX SDK. Go to the JavaFX Release Documentation page for the system requirements and installation instructions for the JavaFX SDK version that you plan to use.
  2. Use the Getting Started with JavaFX tutorial to create a simple application that demonstrates animation.

Additional Resources

Use the following resources to learn more about the JavaFX technology.