3.5 Key Point Summary
This chapter introduces JavaFX and shows you how to write JavaFX programs that display and manipulate scene graph objects. Here are the key points in this chapter.
- JavaFX provides a rich graphical user interface. Its hierarchical scene graph lets you easily configure rich content and provide visually pleasing effects such as gradients, drop shadows, and reflection.
- JavaFX graphics take advantage of hardware-accelerated graphics capabilities for rendering and animation that performs well.
- You can embed JavaFX content within a Swing panel. This lets you use JavaFX without throwing away Swing applications. (See “The Magic of JFXPanel” on page 259.)
- Like Swing, JavaFX uses a single-threaded execution environment.
- You use Java APIs and/or FXML markup with a controller class to create JavaFX content.
- FXML is an XML markup language that lets you specify scene graph content. The hierarchical form of FXML lets you visualize the scene graph structure more easily than with Java APIs. FXML also helps you keep visual content separate from controller code (such as event handlers).
- You configure FXML scene graph nodes using property names and values that convert to the correct types.
- The FXML controller class lets you provide JavaFX node initialization code, dynamic content, and event handlers.
- CSS lets you style JavaFX nodes. You can configure the style property on nodes individually, or provide style sheets for styling an entire application.
- You can specify CSS files either in the main program or in the FXML markup.
- JavaFX provides high-level transitions that let you specify many common animations. This includes movement, rotation, fading in or out, scaling, color changes for fill or stroke properties, and movement along a path.
- JavaFX properties are a significant feature in JavaFX. JavaFX properties are observable and provide similar naming conventions to JavaBeans properties.
- JavaFX properties can be read-write, read-only, or immutable.
- You can attach a ChangeListener or InvalidationListener to any JavaFX property.
- Bindings are more concise and less error-prone than listeners. Bindings are a powerful mechanism that keep application variables synchronized.
- You can create bindings between JavaFX properties that specify a dependency of one property on another. Bindings can be unidirectional or bidirectional.
- Use the Fluent API and Bindings API to specify more complicated binding expressions with one or more properties.
- You can create custom binding objects that specify property dependencies and how to compute the binding’s return value.
With this introduction to JavaFX, you are now ready to learn how to use JavaFX effectively in a desktop application. The approach for these next examples will be similar to the examples we’ve presented previously with Swing.