JavaFX in Action

Chapter 1 is a gentle introduction to the world of rich internet applications: a look at how the web moved from static pages to fully functioning applications, and how Java lost out to Flash in the battle of the applets. As well as comparing JavaFX to its main commercial rivals, the chapter shows a couple of brief JFX code examples, including a comparison with Java/Swing.

Chapter 2 is the first part of the JavaFX Script language tutorial. It focuses on variables and data manipulation, including: basic data types, arithmetic, strings, durations, sequences, and binds. Full examples are given of all the related syntax varients, with notes explaining their purpose, mechanics, and limitations.

Chapter 3 concludes the JavaFX Script language tutorial, by building on the knowledge of variables and data from the previous chapter. This chapter explores common code constructs. Topics covered include: classes, objects, functions, mixin inheritance, access modifiers, conditions and loops.

Chapter 4 is the first project chapter. The main purpose of this chapter is to experiment with the JavaFX Script language — specifically binds and triggers. The project is a simple Sudoku game, using Swing, carefully designed to showcase the most powerful (and unusual) features of JavaFX Script.

The code demonstrates how JFX can make developing Model/View/Controller applications much much easier. For experienced Java/Swing programmers this chapter should be a real eye opener.

The bonus project shows how to auto-validate a form, using binds.

Chapter 5 begins the exploration of the JavaFX scene graph. The project builds on the JavaFX Script skills of the previous chapter, by coding some basic shape manipulation classes, within the framework of a light show application.

The bonus project shows a home-made hypertext link, using text nodes.

Chapter 6 continues the adventures in scene-graph-land. Building on the previous chapter, it looks at how to create complex scenes, that respond to mouse events. Specifically, it shows how to create an animated image button, and an iPhone-style draggable list. It also examines video playback, and node effects (like reflections).

The bonus project shows how to embed custom fonts into a JavaFX application.

Chapter 7 is aimed squarely at business application developers. The project is a simple feedback form, that stores its results, and displays charts and graphs based upon statistics derived from the data. It showcases some of the standard built-in controls that ship with JavaFX 1.2, including buttons, sliders, and radio buttons. It also looks at persistent storage, across multiple devices (including applets and phones). And finally, it studies in detail how to construct a 3D bar graph and pie chart.

The bonus project shows how to write your own skinnable JFX control, and style it using CSS.

Chapter 8 continues the practical theme, this time with a project tied to Flickr's web service. The project starts by developing classes to make a web service call, and parse the reply. These classes are then used to create an image viewer application: Flickr photos are thrown onto a full screen desktop, where they can be picked up and moved around. The code demonstrates several types of off-the-shelf animations, as well as sophisticated interaction with the scene graph.

A bonus section gives some invaluable background detail on the different geometries that can apply to a scene graph node as it is rendered on screen.

Chapter 9 is a bit of fun. The project builds a working Enigma machine, of the type used in World War II to encrypt and decrypt top secret messages. As well as demonstrating some serious data manipulation in JavaFX Script, the project also explains the programmer/designer workflow. The graphical elements on the Enigma interface are constructed in Inkscape, and saved as SVG files, then imported into the Enigma application where they are manipulated directly.

In the final part of the project the Engima application becomes an applet, capable of being ripped from the web page, onto the desktop (complete with modified JNLP file, to provide a custom desktop icon).

The bonus project brings an Inkscape drawing alive, turning it into a working user interface by using carefully labelled IDs.

Chapter 10 has two goals: it pushes the reader's scene graph skills to the max, and it shows how to package applications up for use on a cell phone. The project is a 3D maze game, an early prototype of which can be viewed here.

The bonus section looks at performance tricks and tips, to help keep your scene graphs nibble, and slick.

Chapter 11, the final project, looks at how to use JavaFX from within a Java application. The project is a simple isometric adventure game that uses JavaFX Script code for its in-game events, and to build part of its Swing user interface.