Cover
Copyright
Contents at a Glance
Contents
About the Authors
Foreword
Introduction
1: Getting a Jump Start in JavaFX
A Brief History of JavaFX
Prepare Your JavaFX Journey
Required Tools
JavaFX, the Community
Use the Official Specifications
ScenicView
Developing Your First JavaFX Program: Hello Earthrise
Compiling and Running from the Command Line
Understanding the Hello Earthrise Program
Building and Running the Program with NetBeans
Developing Your Second JavaFX Program: "More Cowbell!"
Building and Running the Audio Configuration Program
The Behavior of the Audio Configuration Program
Understanding the Audio Configuration Program
Colors and Gradients
The Model Class for the Audio Configuration Example
Using InvalidationListeners and Lambda Expressions
Surveying JavaFX Features
Summary
Resources
2: Creating a User Interface in JavaFX
Programmatic Versus Declarative Creation of the User Interface
Introduction to Node-Centric UIs
Setting the Stage
Understanding the Stage Class
Using the Stage Class: The StageCoach Example
Understanding the StageCoach Program
Making a Scene
Using the Scene Class: The OnTheScene Example
Understanding the OnTheScene Program
Handling Input Events
Surveying Mouse, Keyboard, Touch, and Gesture Events and Handlers
Understanding the KeyEvent Class
Understanding the MouseEvent Class
Understanding the TouchEvent Class
Understanding the GestureEvent Class
Animating Nodes in the Scene
Using a Timeline for Animation
Using the Transition Classes for Animation
The Zen of Node Collision Detection
Summary
Resources
3: Using SceneBuilder to Create a User Interface
Setting the Stage with FXML
Creating a User Interface Graphically with JavaFX SceneBuilder
Understanding the FXML File
Understanding the Controller
Understanding the FXMLLoader
Understanding the FXML Loading Facility
Understanding the FXMLLoader Class
Understanding the @FXML Annotation
Exploring the Capabilities of FXML Files
The Deserialization Power of the FXML Format
Understanding Default and Static Properties
Understanding Attribute Resolutions and Bindings
Using Multiple FXML Files
Creating Custom Components Using fx:root
Event Handling Using Scripting or Controller Properties
Using JavaFX SceneBuilder
Overview of JavaFX SceneBuilder
Understanding the Menu Bar and Items
Understanding the Library Panel
Understanding the Document Panel
Understanding the Content Panel
Understanding the Inspector Panel
Summary
Resources
4: Properties and Bindings
Forerunners of JavaFX Binding
A Motivating Example
Understanding Key Interfaces and Concepts
Understanding the Observable Interface
Understanding the ObservableValue Interface
Understanding the WritableValue Interface
Understanding the ReadOnlyProperty Interface
Understanding the Property Interface
Understanding the Binding Interface
Type-Specific Specializations of Key Interfaces
A Common Theme for Type-Specific Interfaces
Commonly Used Classes
Creating Bindings
Understanding the Bindings Utility Class
Understanding the Fluent Interface API
Understanding the JavaFX Beans Convention
The JavaFX Beans Specification
Understanding the Eagerly Instantiated Properties Strategy
Understanding the Lazily Instantiated Properties Strategy
Using Selection Bindings
Adapting JavaBeans Properties to JavaFX Properties
Understanding JavaBeans Properties
Understanding the JavaFX Property Adapters
Summary
Resources
5: Building Dynamic UI Layouts in JavaFX
Introducing JavaFX Reversi
Board Layout and Basic Rules
Building a JavaFX Model for Reversi
Dynamic Layout Techniques
Centering Text Using Bind
Centering Revisited Using a StackPane
Aligning to Edges Using StackPanes and TilePanes
Using FlowPane and Boxes for Directional Alignment
Composing a Layout Using BorderPane
Creating Custom Regions
Building a Custom Square Region
Building a Resizable Reversi Piece
Laying Out the Tiles Using a GridPane
Aligning and Stretching with AnchorPane
When to Use Different Layouts
Bringing Reversi to Life
Highlighting Legal Moves
Highlighting the Active Cell
Taking Turns
Declaring the User Interface Using FXML
Additional Game Enhancements
Summary
Resources
6: Using the JavaFX UI Controls
Trying Out the JavaFX UI Controls
Leveraging the JavaFX UI Controls
Creating a Menu and Defining Menu Items
Creating a Toolbar
Creating a TableView
Creating an Accordion and Defining a TitledPane
Creating a TreeView
Creating a ListView and Assigning Items to a ListView
Creating a SplitPane
Creating a TreeTableView
Defining a ScrollPane
Using a CheckBox
Defining a RadioButton
Creating a Hyperlink
Defining a ChoiceBox
Using a MenuButton
Creating a ContextMenu
Creating a SplitMenuButton
Defining a TextField
Using a PasswordField
Creating a TextArea
Creating a DatePicker and a ColorPicker
Creating a Slider
Defining a ProgressIndicator
Defining a ScrollBar
Using a ProgressBar
Creating an HTMLEditor
Creating a Popup
Using a WebView
Summary
Resources
7: Collections and Concurrency
Understanding Observable Collections and Arrays
Understanding ObservableList
Handling Change Events in ListChangeListener
Understanding ObservableMap
Understanding ObservableSet
Understanding ObservableArrays
Using Factory and Utility Methods from FXCollections
Using the JavaFX Concurrency Framework
Identifying the Threads in a JavaFX Application
Fixing Unresponsive UIs
Understanding the javafx.concurrent Framework
Mixing JavaFX with Other GUI Toolkits
Embedding JavaFX Scenes in Swing Applications
Embedding JavaFX Scenes in SWT Applications
Embedding Swing Components in JavaFX Applications
Summary
Resources
8: Creating Charts in JavaFX
Structure of the JavaFX Chart API
Using the JavaFX PieChart
The Simple Example
Some Modifications
Using the XYChart
Using the ScatterChart
Using the LineChart
Using the BarChart
Using the StackedBarChart
Using the AreaChart
Using the StackedAreaChart
Using the BubbleChart
Summary
Resources
9: Using the Media Classes
The Foundation
Supported Media Formats
Working with Audio Clips
Controlling the Playback Parameters of an AudioClip
Constructing the Scene
AudioClip Wrap-Up
Working with Media
Playing Audio
Error Handling
Displaying Metadata
Loading Media
Controlling Playback
Audio Equalization
MediaPlayer Wrap-Up
Playing Video
Controlling the Size of a MediaView
MediaView and Effects
Using Markers
One Player, Multiple Views
Converting AudioPlayer into a VideoPlayer
Summary
Resources
10: JavaFX 3D
Overview
Understanding JavaFX 3D Objects
Understanding the Shape3D Base Class
Creating Predefined 3D Shapes
Creating User-Defined 3D Shapes
Adding Cameras to JavaFX 3D Scenes
Understanding the PerspectiveCamera
Adding Lights to JavaFX Scenes
Understanding the LightBase Class
Understanding the AmbientLight Class
Understanding the PointLight Class
Understanding SubScenes
Specifying the Material of 3D Shapes
Understanding the PhongMaterial Class
Adding Texture to 3D Shapes
Interacting with JavaFX 3D Scenes
Understanding the PickResult Class
Understanding the Canvas and Image Ops APIs
Understanding the Canvas API
Understanding the Image Ops API
Summary
Resources
11: Accessing Web Services
Front-End and Back-End Platforms
Merging JavaFX and Java Enterprise Modules in the Same Environment
Using JavaFX to Call Remote ⠀圀攀戀) Services
SOAP
REST
Summary
12: JavaFX on Embedded and Mobile
OpenJFX, the Origin of the Code
JavaFX on ARM
The Raspberry Pi
JavaFX on the Raspberry Pi
Deploying JavaFX Applications on the Embedded ARM Systems
JavaFX on Mobile
JavaFX on iOS
JavaFX on Android
JavaFXPorts, Putting It All Together
Summary
Resources
13: JavaFX Languages and Markup
A Quick Comparison of Alternative Languages
Vanishing Circles in Java
Vanishing Circles in Alternative JVM Languages
Making Your JavaFX Groovy
Introduction to GroovyFX
Properties in GroovyFX
GroovyFX Binding
GroovyFX API Enhancements
Scala and JavaFX
Getting Started with ScalaFX
ScalaFX Proxies and Implicit Conversions
JavaFX Properties in Scala
ScalaFX Bind APIs
API Enhancements
Summary
Resources
Index