JavaFX™, the rich UI design system from Sun Microsystems and then Oracle, never really went away. But JavaFX Script 1.x has been replaced by JavaFX 2.x Java APIs. As a fan of JavaFX script (and co-author of Essential JavaFX), I loved working with many of the unique features that JavaFX provided, such as easy animation, a declarative programming style, type inference, function and sequence types, and a powerful binding mechanism. With JavaFX you create a graphical UI by building a scene graph, a tree structure (or directed acyclic graph) consisting of container nodes and leaf nodes. Container nodes hold other nodes and are used for grouping and layout. Leaf nodes are graphical elements (such as images, lines, text, circles, and so on) that don’t contain other elements.
Oracle announced this new direction at JavaOne 2010. A year later and JavaFX 2.0 (the Java API system) has been released. Oracle also announced that JavaFX is open sourced. With approximately 50 talks at JavaOne 2011, Oracle sent the message, “We want you to look at this new JavaFX.” So I did look. I am looking. I am looking and playing and testing. And with all this playing around, I have some mostly good news.
First, for people who have experience with JavaFX script (that is, JavaFX 1.x), many concepts remain the same. You still build a scene graph. You still work with the same familiar graphical objects. You have the same UI controls, but many more. Animation works the same in that you change the value of node properties along a timeline. As before, there are high-level animations, called transitions that simplify animation. By keeping the scene graph and many of the graphical components, JavaFX 2.0 feels familiar. And now I am programming in Java, not JavaFX script. For Java programmers that is very good.
What do I miss? Most of all I miss the easy binding mechanism and the declarative style that makes binding so natural. To be sure, JavaFX 2.0 includes a new Property Binding mechanism that lets you specify binding. It works great. But, it’s not so elegant. JavaFX 2.0 also includes “build” classes that let you create graphical objects using a more declarative style. (I’m not really sure if I’ll use these build classes.)
But back to the good news. Moving JavaFX to Java APIs lets Oracle standardize the system and bring in Java developers. Indeed, FXML lets you specify your scene graph using an XML-based language, which can then be manipulated by UI builder tools. JavaFX 2.0 has an improved event handling model, improved performance (using graphics hardware when available), improved cross-platform support, some 3-D support, and an improved thread model. I am ready to give JavaFX a go! Stay tuned for some example programs coming soon.
Note: To view many of the JavaFX talks presented at JavaOne 2011, see this link.