You are previewing Learn JavaFX 8: Building User Experience and Interfaces with Java 8.
O'Reilly logo
Learn JavaFX 8: Building User Experience and Interfaces with Java 8

Book Description

Learn JavaFX 8 shows you how to start developing rich-client desktop applications using your Java skills and provides comprehensive coverage of JavaFX 8's features. Each chapter starts with an introduction to the topic at hand, followed by a step-by-step discussion of the topic with small snippets of code. The book contains numerous figures aiding readers in visualizing the GUI that is built at every step in the discussion.

The book starts with an introduction to JavaFX and its history. It lists the system requirements and the steps to start developing JavaFX applications. It shows you how to create a Hello World application in JavaFX, explaining every line of code in the process. Later in the book, author Kishori Sharan discusses advanced topics such as 2D and 3D graphics, charts, FXML, advanced controls, and printing. Some of the advanced controls such as TableView, TreeTableView and WebView are covered at length in separate chapters.

This book provides complete and comprehensive coverage of JavaFX 8 features; uses an incremental approach to teach JavaFX, assuming no prior GUI knowledge; includes code snippets, complete programs, and pictures; covers MVC patterns using JavaFX; and covers advanced topics such as FXML, effects, transformations, charts, images, canvas, audio and video, DnD, and more. So, after reading and using this book, you'll come away with a comprehensive introduction to the JavaFX APIs as found in the new Java 8 platform.

Table of Contents

  1. Cover
  2. Title
  3. Copyright
  4. Dedication
  5. Contents at a Glance
  6. Contents
  7. About the Author
  8. About the Technical Reviewers
  9. Acknowledgments
  10. Introduction
  11. Chapter 1: Getting Started
    1. What Is JavaFX?
    2. History of JavaFX
    3. System Requirements
    4. JavaFX Runtime Library
    5. JavaFX Source Code
    6. Your First JavaFX Application
      1. Creating the HelloJavaFX Class
      2. Overriding the start() Method
      3. Showing the Stage
      4. Launching the Application
      5. Adding the main() Method
      6. Adding a Scene to the Stage
    7. Improving the HelloFX Application
    8. Using the NetBeans IDE
      1. Creating a New JavaFX Project
      2. Opening an Existing JavaFX Project
      3. Running a JavaFX Project from the NetBeans IDE
    9. Passing Parameters to a JavaFX Application
      1. Case 1
      2. Case 2
      3. Case 3
      4. Case 4
    10. Launching a JavaFX Application
    11. The Life Cycle of a JavaFX Application
    12. Terminating a JavaFX Application
    13. Summary
  12. Chapter 2: Properties and Bindings
    1. What Is a Property?
    2. What Is a Binding?
    3. Understanding Bindings Support in JavaBeans
    4. Understanding Properties in JavaFX
    5. Using Properties in JavaFX Beans
    6. Lazily Instantiating Property Objects
    7. Understanding the Property Class Hierarchy
    8. Handling Property Invalidation Events
    9. Handling Property Change Events
    10. Avoiding Memory Leaks in Listeners
    11. Handling Invalidation and Change Events
    12. Using Bindings in JavaFX
    13. Unidirectional and Bidirectional Bindings
    14. Understanding the Binding API
      1. The High-Level Binding API
      2. Using the Low-Level Binding API
    15. Using Bindings to Center a Circle
    16. Summary
  13. Chapter 3: Observable Collections
    1. What Are Observable Collections?
    2. Understanding ObservableList
      1. Creating an ObservableList
      2. Observing an ObservableList for Invalidations
      3. Observing an ObservableList for Changes
    3. Understanding ObservableSet
      1. Creating an ObservableSet
      2. Observing an ObservableSet for Invalidations
      3. Observing an ObservableSet for Changes
    4. Understanding ObservableMap
      1. Creating an ObservableMap
      2. Observing an ObservableMap for Invalidations
      3. Observing an ObservableMap for Changes
    5. Properties and Bindings for JavaFX Collections
      1. Understanding ObservableList Property and Binding
      2. Understanding ObservableSet Property and Binding
      3. Understanding ObservableMap Property and Binding
    6. Summary
  14. Chapter 4: Managing Stages
    1. Knowing the Details of Your Screens
    2. What Is a Stage?
    3. Showing the Primary Stage
    4. Setting the Bounds of a Stage
    5. Initializing the Style of a Stage
    6. Moving an Undecorated Stage
    7. Initializing Modality of a Stage
    8. Setting the Opacity of a Stage
    9. Resizing a Stage
    10. Showing a Stage in Full-Screen Mode
    11. Showing a Stage and Waiting for It to Close
    12. Summary
  15. Chapter 5: Making Scenes
    1. What Is a Scene?
    2. Graphics Rendering Modes
    3. Setting the Cursor for a Scene
    4. The Focus Owner in a Scene
    5. Using Builder Classes
    6. Understanding the Platform Class
    7. Knowing the Host Environment
    8. Summary
  16. Chapter 6: Understanding Nodes
    1. What Is a Node?
    2. The Cartesian Coordinate System
    3. Cartesian Coordinate System of a Node
    4. The Concept of Bounds and Bounding Box
    5. Knowing the Bounds of a Node
      1. The layoutBounds Property
      2. The boundsInLocal Property
      3. The boundsInParent Property
    6. Bounds of a Group
    7. A Detailed Example on Bounds
    8. Positioning a Node Using layoutX and layoutY
    9. Setting the Size of a Node
      1. Resizable Nodes
      2. Nonresizable Nodes
    10. Storing User Data in a Node
    11. What Is a Managed Node?
    12. Transforming Bounds between Coordinate Spaces
    13. Summary
  17. Chapter 7: Playing with Colors
    1. Understanding Colors
      1. Using the Color Class
      2. Using the ImagePattern Class
    2. Understanding Linear Color Gradient
      1. Using the LinearGradient Class
      2. Defining Linear Color Gradients Using a String Format
    3. Understanding Radial Color Gradient
      1. Using the RadialGradient Class
      2. Defining Radial Color Gradients in String Format
    4. Summary
  18. Chapter 8: Styling Nodes
    1. What Is a Cascading Style Sheet?
    2. What are Styles, Skins, and Themes?
    3. A Quick Example
    4. Naming Conventions in JavaFX CSS
    5. Adding Style Sheets
    6. Default Style Sheet
    7. Adding Inline Styles
    8. Priorities of Styles for a Node
    9. Inheriting CSS Properties
    10. Types of CSS Properties
      1. The inherit Type
      2. The boolean Type
      3. The string Type
      4. The number Type
      5. The angle Type
      6. The point Type
      7. The color-stop Type
      8. The URI Type
      9. The effect Type
      10. The font Type
      11. The paint Type
    11. Specifying Background Colors
    12. Specifying Borders
      1. Border Colors
      2. Border Widths
      3. Border Radii
      4. Border Insets
      5. Border Styles
    13. Understanding Style Selectors
      1. Using Class Selectors
      2. Class Selector for the root Node
      3. Using ID Selectors
      4. Combining ID and Class Selectors
      5. The Universal Selector
      6. Grouping Multiple Selectors
      7. Descendant Selectors
      8. Child Selectors
      9. State-Based Selectors
      10. Using JavaFX Class Names as Selectors
    14. Looking Up Nodes in a Scene Graph
    15. Using Compiled Style Sheets
    16. Summary
  19. Chapter 9: Event Handling
    1. What Is an Event?
    2. Event Class Hierarchy
    3. Event Targets
    4. Event Types
    5. Event Processing Mechanism
      1. Event Target Selection
      2. Event Route Construction
      3. Event Route Traversal
    6. Handling Events
      1. Creating Event Filters and Handlers
      2. Registering Event Filters and Handlers
    7. Execution Order of Event Filters and Handlers
    8. Consuming Events
    9. Handling Input Events
    10. Handling Mouse Events
      1. Getting Mouse Location
      2. Representing Mouse Buttons
      3. State of Mouse Buttons
      4. Hysteresis in GUI Applications
      5. State of Modifier Keys
      6. Picking Mouse Events on Bounds
      7. Mouse Transparency
      8. Synthesized Mouse Events
      9. Handling Mouse Entered and Exited Events
    11. Handling Key Events
      1. Handling Key-pressed and Key-released Events
      2. Handling the Key-typed Event
    12. Handling Window Events
    13. Summary
  20. Chapter 10: Understanding Layout Panes
    1. What Is a Layout Pane?
    2. Layout Pane Classes
    3. Adding Children to a Layout Pane
    4. Utility Classes and Enums
      1. The Insets Class
      2. The HPos Enum
      3. The VPos Enum
      4. The Pos Enum
      5. The HorizontalDirection Enum
      6. The VerticalDirection Enum
      7. The Orientation Enum
      8. The Side Enum
      9. The Priority Enum
    5. Understanding Group
      1. Creating a Group Object
      2. Rendering Nodes in a Group
      3. Positioning Nodes in a Group
      4. Applying Effects and Transformations to a Group
      5. Styling a Group with CSS
    6. Understanding Region
      1. Setting Backgrounds
      2. Setting Padding
      3. Setting Borders
      4. Setting Margins
    7. Understanding Panes
    8. Understanding HBox
      1. Creating HBox Objects
      2. HBox Properties
      3. Setting Constraints for Children in HBox
    9. Understanding VBox
      1. Creating VBox Objects
      2. VBox Properties
      3. Setting Constraints for Children in VBox
    10. Understanding FlowPane
      1. Creating FlowPane Objects
      2. FlowPane Properties
      3. Content Bias of a FlowPane
    11. Understanding BorderPane
      1. Creating BorderPane Objects
      2. BorderPane Properties
      3. Setting Constraints for Children in BorderPane
    12. Understanding StackPane
      1. Creating StackPane Objects
      2. StackPane Properties
      3. Setting Constraints for Children
    13. Understanding TilePane
      1. Creating TilePane Objects
      2. TilePane Properties
      3. Setting Constraints for Children in TilePane
    14. Understanding GridPane
      1. Creating GridPane Objects
      2. Making Grid Lines Visible
      3. Adding Children to GridPane
      4. Creating Forms Using GridPanes
      5. GridPane Properties
      6. The hgap and vgap Properties
      7. Customizing Columns and Rows
      8. Setting Constraints on Children in GridPane
    15. Understanding AnchorPane
      1. Creating AnchorPane Objects
      2. Setting Constraints for Children in AnchorPane
    16. Understanding TextFlow
      1. Creating TextFlow Objects
      2. TextFlow Properties
      3. Setting Constraints for Children in TextFlow
    17. Snapping to Pixel
    18. Summary
  21. Chapter 11: Model-View-Controller Pattern
    1. What Is the Model-View-Controller Pattern?
    2. A Model-View-Presenter Example
      1. The Requirements
      2. The Design
      3. The Implementation
      4. Putting Them Together
    3. Summary
  22. Chapter 12: Understanding Controls
    1. What Is a Control?
    2. Understanding Control Classes Hierarchy
    3. Labeled Controls
      1. Positioning Graphic and Text
      2. Understanding Mnemonics and Accelerators
    4. Understanding the Label Control
    5. Understanding Buttons
    6. Understanding Command Buttons
      1. Understanding the Button Control
      2. Understanding the Hyperlink Control
      3. Understanding the MenuButton Control
    7. Understanding Choice Buttons
      1. Understanding the ToggleButton Control
      2. Understanding the RadioButton Control
      3. Understanding the CheckBox Control
    8. Understanding the Hybrid Button Control
    9. Making Selections from a List of Items
    10. Understanding the ChoiceBox Control
      1. Using Domain Objects in ChoiceBox
      2. Allowing Nulls in ChoiceBox
      3. Using Separators in ChoiceBox
      4. Styling a ChoiceBox with CSS
    11. Understanding the ComboBox Control
      1. Detecting Value Change in ComboBox
      2. Using Domain Objects in Editable ComboBox
      3. Customizing the Height of Pop-up List
      4. Using Nodes as Items in ComboBox
      5. Using a Cell Factory in ComboBox
      6. Styling ComboBox with CSS
    12. Understanding the ListView Control
      1. Orientation of a ListView
      2. Selection Model in ListView
      3. Using Cell Factory in ListView
      4. Using Editable ListView
      5. Handling Events While Editing a ListView
      6. Styling ListView with CSS
    13. Understanding the ColorPicker Control
      1. Using the ColorPicker Control
      2. Styling ColorPicker with CSS
    14. Understanding the DatePicker Control
      1. Using the DatePicker Control
      2. Styling DatePicker with CSS
    15. Understanding Text Input Controls
      1. Positioning and Moving Caret
      2. Making Text Selection
      3. Modifying the Content
      4. Cutting, Copying, and Pasting Text
      5. An Example
      6. Styling TextInputControl with CSS
    16. Understanding the TextField Control
      1. Styling TextField with CSS
    17. Understanding the PasswordField Control
    18. Understanding the TextArea Control
      1. Styling TextArea with CSS
    19. Showing the Progress of a Task
      1. Styling ProgressIndicator with CSS
      2. Styling ProgressIndicator and Bar with CSS
    20. Understanding the TitledPane Control
      1. Styling TitledPane with CSS
    21. Understanding the Accordion Control
      1. Styling Accordion with CSS
    22. Understanding the Pagination Control
      1. Styling Pagination with CSS
    23. Understanding the Tool Tip Control
      1. Styling Tooltip with CSS
    24. Providing Scrolling Features in Controls
      1. Understanding the ScrollBar Control
      2. Understanding the ScrollPane Control
    25. Keeping Things Separate
      1. Understanding the Separator Control
      2. Styling Separator with CSS
      3. Understanding the SplitPane Control
      4. Styling SplitPane with CSS
    26. Understanding the Slider Control
      1. Styling Slider with CSS
    27. Understanding Menus
      1. Using Menu Bars
      2. Using Menus
      3. Using Menu Items
      4. Putting All Parts of Menus Together
      5. Styling Menus Using CSS
    28. Understanding the ContextMenu Control
      1. Styling ContextMenu with CSS
    29. Understanding the ToolBar Control
      1. Styling a Toolbar with CSS
    30. Understanding TabPane and Tab
      1. Creating Tabs
      2. Setting the Title and Content of Tabs
      3. Creating TabPanes
      4. Adding Tabs to a TabPane
      5. Putting TabPanes and Tabs Together
      6. Understanding Tab Selection
      7. Closing Tabs in a TabPane
      8. Positioning Tabs in a TabPane
      9. Sizing Tabs in a TabPane
      10. Using Recessed and Floating TabPanes
      11. Styling Tab and TabPane with CSS
    31. Understanding the HTMLEditor Control
      1. Creating an HTMLEditor
      2. Using an HTMLEditor
      3. Styling HTMLEditor with CSS
    32. Choosing Files and Directories
      1. The FileChooser Dialog
      2. The DirectoryChooser Dialog
    33. Summary
  23. Chapter 13: Understanding TableView
    1. What Is a TableView ?
    2. Creating a TableView
      1. Adding Columns to a TableView
      2. Customizing TableView Placeholder
      3. Populating a TableColumn with Data
    3. Using a Map as Items in a TableView
      1. Showing and Hiding Columns
      2. Reordering Columns in a TableView
    4. Sorting Data in a TableView
      1. Sorting Data by Users
      2. Sorting Data Programmatically
    5. Customizing Data Rendering in Cells
    6. Selecting Cells and Rows in a TableView
    7. Editing Data in a TableView
      1. Editing Data Using a Check Box
      2. Editing Data Using a Choice Box
      3. Editing Data Using a Combo Box
      4. Editing Data Using a TextField
      5. Editing Data in TableCell Using any Control
    8. Adding and Deleting Rows in a TableView
    9. Scrolling in a TableView
    10. Resizing a TableColumn
    11. Styling a TableView with CSS
    12. Summary
  24. Chapter 14: Understanding TreeView
    1. What Is a TreeView ?
    2. Creating a TreeView
    3. Hiding the Root Node
      1. Understanding the TreeItem
    4. Handling TreeItem Events
    5. Adding and Removing Nodes
    6. Customizing Cells in a TreeView
    7. Editing Data in a TreeView
      1. Editing Data using a Check Box
      2. Editing Data Using a Choice Box
      3. Editing Data Using a Combo Box
      4. Editing Data Using a TextField
    8. Loading TreeItems on Demand
    9. Scrolling to a TreeItem
    10. TreeView Selection Model
    11. Styling TreeView with CSS
    12. Summary
  25. Chapter 15: Understanding TreeTableView
    1. What Is a TreeTableView?
    2. Model for TreeTableView
    3. Creating a TreeTableView
    4. Sorting Data in a TreeTableView
    5. Populating a TreeTableColumn with Data
    6. Showing and Hiding Columns
    7. Customizing Data Rendering in Cells
    8. Selecting Cells and Rows in a TreeTableView
    9. Editing Data in a TableView
    10. Adding and Deleting Rows in a TableView
    11. Scrolling in a TreeTableView
    12. StylingTreeTableView with CSS
    13. Summary
  26. Chapter 16: Browsing Web Pages
    1. What Is a WebView?
    2. Creating a Web Browser Component
    3. Setting Properties for a WebView
    4. Enhancing the Web Browser Application
    5. Accessing Browsing History
    6. Handling JavaScript UI Requests
    7. Executing JavaScript Code from JavaFX
    8. Executing JavaFX Code from JavaScript
    9. Accessing the DOM
    10. Setting the User-Agent HTTP Header
    11. Setting a User Style Sheet
    12. Styling a WebView with CSS
    13. Summary
  27. Chapter 17: Understanding 2D Shapes
    1. What Are 2D Shapes?
    2. Drawing 2D Shapes
      1. Drawing Lines
      2. Drawing Rectangles
      3. Drawing Circles
      4. Drawing Ellipses
      5. Drawing Polygons
      6. Drawing Polylines
      7. Drawing Arcs
      8. Drawing Quadratic Curves
      9. Drawing Cubic Curves
    3. Building Complex Shapes Using the Path Class
      1. The MoveTo Path Element
      2. The LineTo Path Element
      3. The HLineTo and VLineTo Path Elements
      4. The ArcTo Path Element
      5. The QuadCurveTo Path Element
      6. The CubicCurveTo Path Element
      7. The ClosePath Path Element
      8. The Fill Rule for a Path
    4. Drawing Scalable Vector Graphics
      1. The “moveTo” Command
      2. The“lineto” Commands
      3. The“arcto” Command
      4. The“Quadratic Bezier curveto” Command
      5. The“Cubic Bezier curveto” Command
      6. The “closepath” Command
    5. Combining Shapes
    6. Understanding the Stroke of a Shape
    7. Styling Shapes with CSS
    8. Summary
  28. Chapter 18: Understanding Text Nodes
    1. What Is a Text Node?
    2. Creating a Text Node
    3. Understanding the Text Origin
    4. Displaying Multiline Text
    5. Setting Text Fonts
      1. Creating Fonts
      2. Accessing Installed Fonts
      3. Using Custom Fonts
    6. Setting Text Fill and Stroke
    7. Applying Text Decorations
    8. Applying Font Smoothing
    9. Styling a Text Node with CSS
    10. Summary
  29. Chapter 19: Understanding 3D Shapes
    1. What Are 3D Shapes?
    2. Checking Support for 3D
    3. The 3D Coordinate System
    4. Rendering Order of Nodes
    5. Using Predefined 3D Shapes
      1. Specifying the Shape Material
      2. Specifying the Draw Mode of Shapes
      3. Specifying the Face Culling for Shapes
    6. Using Cameras
    7. Using Light Sources
    8. Creating Subscenes
    9. Creating User-Defined Shapes
      1. Creating a 3D Triangle
      2. Creating a 3D Rectangle
      3. Creating a Tetrahedron
    10. Summary
  30. Chapter 20: Applying Effects
    1. What Is an Effect?
    2. Chaining Effects
    3. Shadowing Effects
      1. The DropShadow Effect
      2. The InnerShadow Effect
      3. The Shadow Effect
    4. Blurring Effects
      1. The BoxBlur Effect
      2. The GaussianBlur Effect
      3. The MotionBlur Effect
    5. The Bloom Effect
    6. The Glow Effect
    7. The Reflection Effect
    8. The SepiaTone Effect
    9. The DisplacementMap Effect
    10. The ColorInput Effect
    11. The ColorAdjust Effect
    12. The ImageInput Effect
    13. The Blend Effect
    14. The Lighting Effect
      1. Customizing the Surface Texture
      2. Understanding Reflection Types
      3. Understanding the Light Source
    15. The PerspectiveTransform Effect
    16. Summary
  31. Chapter 21: Understanding Transformations
    1. What Is a Transformation?
    2. The Translation Transformation
    3. The Rotation Transformation
    4. The Scale Transformation
    5. The Shear Transformation
    6. Applying Multiple Transformations
    7. Summary
  32. Chapter 22: Understanding Animation
    1. What Is Animation?
    2. Understating Animation Classes
    3. Understanding Utility Classes
      1. Understanding the Duration Class
      2. Understating the KeyValue Class
      3. Understanding the KeyFrame Class
    4. Understating the Timeline Animation
    5. Controlling an Animation
      1. Playing an Animation
      2. Delaying the Start of an Animation
      3. Stopping an Animation
      4. Pausing an Animation
      5. Knowing the State of an Animation
      6. Looping an Animation
      7. Auto Reversing an Animation
      8. Attaching an onFinished Action
      9. Knowing the Duration of an Animation
      10. Adjusting the Speed of an Animation
    6. Understanding Cue Points
    7. Understanding Transitions
      1. Understanding the Fade Transition
      2. Understanding the Fill Transition
      3. Understanding the Stroke Transition
      4. Understanding the Translate Transition
      5. Understanding the Rotate Transition
      6. Understanding the Scale Transition
      7. Understanding the Path Transition
      8. Understanding the Pause Transition
      9. Understanding the Sequential Transition
      10. Understanding the Parallel Transition
    8. Understanding Interpolators
      1. Understanding the Linear Interpolator
      2. Understanding the Discrete Interpolator
      3. Understanding the Ease-In Interpolator
      4. Understanding the Ease-Out Interpolator
      5. Understanding the Ease-Both Interpolator
      6. Understanding the Spline Interpolator
      7. Understanding the Tangent Interpolator
    9. Summary
  33. Chapter 23: Understanding Charts
    1. What Is a Chart?
    2. Understating the Chart API
    3. Styling Charts with CSS
    4. Data Used in Chart Examples
    5. Understanding the PieChart
      1. Customizing Pie Slices
      2. Styling the PieChart with CSS
    6. Understating the XYChart
      1. Representing Axes in an XYChart
      2. Adding Data to an XYChart
    7. Understating the BarChart
      1. Styling the BarChart with CSS
    8. Understating the StackedBarChart
      1. Styling the StackedBarChart with CSS
    9. Understanding the ScatterChart
      1. Styling the ScatterChart with CSS
    10. Understanding the LineChart
      1. Styling the LineChart with CSS
    11. Understating the BubbleChart
      1. Styling the BubbleChart with CSS
    12. Understating the AreaChart
      1. Styling the AreaChart with CSS
    13. Understanding the StackedAreaChart
      1. Styling the StackedAreaChart with CSS
    14. Customizing XYChart Appearance
      1. Setting Alternate Row/Column Fill
      2. Showing Zero Line Axes
      3. Showing Grid Lines
      4. Formatting Numeric Tick Labels
    15. Summary
  34. Chapter 24: Understanding the Image API
    1. What Is the Image API?
    2. Loading an Image
      1. Specifying the Image-Loading Properties
      2. Reading the Loaded-Image Properties
    3. Viewing an Image
      1. Multiple Views of an Image
      2. Viewing an Image in a Viewport
    4. Understanding Image Operations
      1. Pixel Formats
      2. Reading Pixels from an Image
      3. Writing Pixels to an Image
      4. Creating an Image from Scratch
      5. Saving a New Image to a FileSystem
    5. Taking the Snapshot of a Node and a Scene
      1. Taking the Snapshot of a Node
      2. Taking the Snapshot of a Scene
    6. Summary
  35. Chapter 25: Drawing on a Canvas
    1. What Is the Canvas API?
    2. Creating a Canvas
    3. Drawing on the Canvas
      1. Drawing Basic Shapes
      2. Drawing Text
      3. Drawing Paths
      4. Drawing Images
      5. Writing Pixels
    4. Clearing the Canvas Area
    5. Saving and Restoring the Drawing States
    6. A Canvas Drawing Example
    7. Summary
  36. Chapter 26: Understanding Drag and Drop
    1. What Is a Press-Drag-Release Gesture?
      1. A Simple Press-Drag-Release Gesture
      2. A Full Press-Drag-Release Gesture
      3. A Drag-and-Drop Gesture
    2. Understanding the Data Transfer Modes
    3. Understanding the Dragboard
    4. The Example Application
      1. Initiating the Drag-and-Drop Gesture
      2. Detecting a Drag Gesture
      3. Dropping the Source onto the Target
      4. Completing the Drag-and-Drop Gesture
    5. Providing Visual Clues
    6. A Complete Drag-and-Drop Example
    7. Transferring an Image
    8. Transferring Custom Data Types
    9. Summary
  37. Chapter 27: Understanding Concurrency in JavaFX
    1. The Need for a Concurrency Framework
    2. Understating the Concurrent Framework API
    3. Understanding the Worker<V> Interface
      1. State Transitions for a Worker
      2. Properties of a Worker
      3. Utility Classes for Examples
    4. Using the Task<V> Class
      1. Creating a Task
      2. Updating Task Properties
      3. Listening to Task Transition Events
      4. Cancelling a Task
      5. Running a Task
      6. A Prime Finder Task Example
    5. Using the Service<V> Class
      1. Creating the Service
      2. Updating Service Properties
      3. Listening to Service Transition Events
      4. Cancelling the Service
      5. Starting the Service
      6. Resetting the Service
      7. Restarting the Service
      8. The Prime Finder Service Example
    6. Using the ScheduledService<V> Class
      1. Creating the ScheduledService
      2. Updating ScheduledService Properties
      3. Listening to ScheduledService Transition Events
      4. The Prime Finder ScheduledService Example
    7. Summary
  38. Chapter 28: Playing Audios and Videos
    1. Understanding the Media API
    2. Playing Short Audio Clips
    3. Playing Media
      1. Creating a Media Object
      2. Creating a MediaPlayer Object
      3. Creating a MediaView Node
      4. Combining Media, MediaPlayer, and MediaView
    4. A Media Player Example
    5. Handling Playback Errors
    6. State Transitions of the MediaPlayer
    7. Repeating Media Playback
    8. Tracking Media Time
    9. Controlling the Playback Rate
    10. Controlling the Playback Volume
    11. Positioning the MediaPlayer
    12. Marking Positions in the Media
    13. Showing Media Metadata
    14. Customizing the MediaView
    15. Developing a Media Player Application
    16. Summary
  39. Chapter 29: Understanding FXML
    1. What Is FXML?
    2. Editing FXML Documents
    3. FXML Basics
      1. Creating the FXML File
      2. Adding UI Elements
      3. Importing Java Types in FXML
      4. Setting Properties in FXML
      5. Specifying FXML Namespace
      6. Assigning an Identifier to an Object
      7. Adding Event Handlers
      8. Loading FXML Documents
      9. Using a Controller in FXML
    4. Creating Objects in FXML
      1. Using the no-args Constructor
      2. Using the static valueOf() Method
      3. Using a Factory Method
      4. Using Builders
    5. Creating Reusable Objects in FXML
    6. Specifying Locations in Attributes
    7. Using Resource Bundles
    8. Including FXML Files
    9. Using Constants
    10. Referencing Another Element
    11. Copying Elements
    12. Binding Properties in FXML
    13. Creating Custom Controls
    14. Summary
  40. Chapter 30: Understanding the Print API
    1. What is the Printing API?
    2. Listing Available Printers
    3. Getting the Default Printer
    4. Printing Nodes
    5. Showing the Page Setup and Print Dialogs
    6. Customizing PrinterJob Settings
    7. Setting Page Layout
    8. Printing a Webpage
    9. Summary
  41. Index