Tuesday, January 3, 2012

JavaFX 2's Ensemble and other Sample Applications

There are several places within the JavaFX 2 documentation that the sample application Ensemble is referenced. Ensemble is the largest JavaFX sample application provided in the JavaFX 2.0 samples. Acquiring the JavaFX 2 samples, using the JavaFX 2 samples, and learning from the JavaFX 2 samples are the subjects of this post.

The JavaFX Developer Downloads page currently features "JavaFX 2.0.2 General Availability Download" and includes a link for downloading JavaFX Samples [only for "Microsoft Windows (x86 and x64)" as of this writing]. The downloaded file, javafx_samples-2_0_2.zip, is about 18 MB in size. The contents of this ZIP file, when extracted are shown in the next screen snapshot.

Once the samples ZIP has been downloaded and its contents extracted, the Ensemble sample application can be executed. One way to do this is to take advantage of the executable JAR in the main unzipped samples directory as shown in the next screen snapshot (java -jar Ensemble.jar).

The JavaFX 2 Ensemble sample application starts up and appears as shown in the next screen snapshot.

There are numerous items that can be clicked on in the Ensemble application to learn more details about what it is and how it is implemented. For example, clicking on "Adv Candle Stick Chart" opens up the "Custom Candle Stick Chart" as shown in the next screen snapshot.

The above screen snapshot shows Ensemble with the "Sample" tab for this specific example. Clicking on the "Source Code" tab displays the source code for the same sample. As shown in the next screen snapshot, this tab includes a button for copying the JavaFX 2 source code that built that sample.

The combination of the source code with what it produces in the Ensemble sample application can help developers to learn what's available and how to use various parts of JavaFX. Sections currently included in Ensemble include Animation, Charts, Controls, Graphics, Language, Layout, Media, Scene Graph, and Web.

The downloadable JavaFX 2 samples also include Brick Breaker (BrickBreaker.jar) and the next screen snapshot was taken of it in action.

Running the executable JAR SwingInterop.jar demonstrates the "JavaFX 2.0 in Swing" sample application (screen snapshot shown next).

The JavaFX 2 samples ZIP also includes FXML-LoginDemo, which is a simple login sample that includes an FXML file (profile.fxml) in its source. It's shown in the next screen snapshot.

The Ensemble application is by far the largest of the sample applications that are included in the JavaFX 2 samples ZIP file and is the "flagship" sample application. Brick Breaker is relatively large for a single application. All of the samples have value in showing what JavaFX is capable of and in providing source code to demonstrate how to accomplish these very feats with JavaFX.

1 comment:

Glaceon5 said...

A version of the JavaFX samples for Mac OS X is available on the JavaFX 2.1 Developer Preview page http://www.oracle.com/technetwork/java/javafx/downloads/devpreview-1429449.html