Mastering JavaFX 10

Book description

Design modern, rich interfaces for Java apps using JavaFX 10

About This Book
  • Become a pro with the latest JavaFX 10 framework
  • Create dynamic content using the animation API
  • Create and customize plugins and use them efficiently in different applications
Who This Book Is For

If you're a Java developer who wants to upgrade to the latest version of JavaFX to create stunning, feature-rich graphical applications, this book is for you.

What You Will Learn
  • Construct and customize JavaFX windows
  • Manage UI elements and arrange them on the Scene
  • Explore the Bindings API and use it to coordinate various UI elements
  • Use FXML to design amazing FX applications
  • Write and manage CSS to style your applications
  • Add audio and video to your projects
  • Prepare your application to be launched on the target platform
In Detail

JavaFX 10 is used to create media-rich client applications. This book takes you on a journey to use JavaFX 10 to build applications that display information in a high-performance, modern user interface featuring audio, video, graphics, and animation.

Mastering JavaFX 10 begins by introducing you to the JavaFX API. You will understand the steps involved in setting up your development environment and build the necessary dependencies. This is followed by exploring how to work with the assets, modules, and APIs of JavaFX. This book is filled with practical examples to guide you through the major features of JavaFX 10. In addition to this, you will acquire a practical understanding of JavaFX custom animations, merging different application layers smoothly, and creating a user-friendly GUI with ease.

By the end of the book, you will be able to create a complete, feature-rich Java graphical application using JavaFX.

Style and approach

The book adopts a practical, step-by-step approach.

Publisher resources

Download Example Code

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Mastering JavaFX 10
  3. Dedication
    1. Why subscribe?
  5. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  7. Stages, Scenes, and Layout
    1. Application and JavaFX subsystems
      1. Components of the JavaFX toolkit
        1. Glass toolkit
        2. Prism and Quantum Toolkit
        3. Media
        4. WebView/WebEngine
      2. Working with JavaFX Application Thread
      3. Application class
        1. Using the Application.launch() method
      4. Managing command-line parameters
      5. Closing the JavaFX application
    2. Stage – a JavaFX term for the window
      1. Working with Stage modality options
      2. Using Stage styles
      3. Setting fullscreen and other window options
    3. Scene and SceneGraph
    4. Organizing the Scene content with Layout Managers
      1. Free layout
        1. The most basic layout manager – Group
        2. Region and Pane layout managers
      2. Behavioral layout
      3. Positional layout
        1. TilePane and FlowPane
        2. BorderPane layout manager
        3. AnchorPane layout manager
        4. GridPane layout manager
    5. Clock demo
    6. Summary
  8. Building Blocks – Shapes, Text, and Controls
    1. Shapes and their properties
      1. JavaFX shapes overview
        1. Closed shapes
        2. Lines
        3. Curves
        4. Paths
      2. Adding Text to the JavaFX scene
      3. Controlling Shape's color
        1. Paint
        2. ImagePattern
        3. Gradients
      4. Customizing lines with Stroke API
        1. Basic Stroke
        2. Dashed lines
        3. Connecting line designs using Line Join
      5. Working with the Shape operations
    2. Transformations
    3. Coordinates and bounds
      1. Working with Bounds Demo
      2. Using the ScenicView tool to study JavaFX scenegraph 
    4. Basic Controls
      1. Button and Event Handlers
      2. Size of the Controls
    5. Clock demo
    6. Summary
  9. Connecting Pieces – Binding
    1. Working with the Property API
      1. Using the Observable API
      2. Introducing the Binding API
        1. Rules of binding
          1.  Read-only properties  
          2. Binding is a one-to-many relation
          3. Binding blocks setters
          4. Bidirectional binding
        2. Using binding for visual help
      3. The role of listeners
    2. Using binding operations
      1. String operations
      2. Arithmetic operations
      3. Boolean operations
    3. Working with bidirectional binding and converters
    4. Creating custom bindings
      1. Implementing base binding classes
      2. Bindings helper function
    5. Understanding binding collections
    6. Summary
  10. FXML
    1. Introduction to FXML
      1. Basics of FXML
      2. Benefits of FXML
      3. Limitations of FXML
    2. Working with FXML loaders
      1. Working with resources
      2. Using the FXMLLoader API
      3. Working with the fx:root attribute and custom components
    3. Working with Controllers
      1. Enhancing Controllers
      2. Using a preconstructed Controller
      3. Working with data
    4. Syntax details of FXML
      1. Reviewing the basics of FXML
      2. Importing packages
      3. Including other FXML files
      4. Using FXML defines
      5. Default properties
      6. Referring to resources from FXML
      7. Adding business logic to FXML
      8. Using static methods in FXML
    5. SceneBuilder
      1. Working with a WYSIWYG editor
      2. Features
      3. Specifying CSS files through the Preview menu
      4. Localization in Preview
    6. Summary
  11. Animation
    1. What is an animation?
      1. Animation example
      2. Understanding KeyFrame and KeyValue
      3. Adding handlers and timers
      4. Working with the Timeline API
      5. Adding cue points
    2. Using the Interpolator API
      1. Predefined interpolators
    3. Using transitions – the predefined animations
      1. Using movement and resize transitions
        1. Using TranslateTransition
        2. Using PathTransition
        3. Using RotateTransition
        4. Using ScaleTransition
      2. Working with color transitions
      3. Combining transitions
    4. Building an animated application
    5. Summary
  12. Styling Applications with CSS
    1. Introduction to CSS
      1. FirstStyles demonstration
      2. Matching JavaFX nodes using selectors
        1. Understanding naming convention for style classes and properties
        2. Using type selectors
        3. Styling specific objects using ID selectors
    2. Loading CSS files from the JavaFX code
    3. Applying styles to JavaFX nodes
      1. Having several CSS files in one JavaFX application
      2. Using the setStyle() method
      3. Calling a corresponding API method
      4. Referring to CSS styles from FXML
      5. Using global JavaFX style sheets
      6. Understanding cascading – the priority scheme for different styling methods
    4. Working with advanced CSS syntax
      1. Using pseudo-classes
      2. Working with descendant selectors
      3. Working with imports, fonts, and URLs
      4. Working with constants and the inherit keyword
    5. Why use CSS?
    6. Using the CSS API
      1. Introducing ClockControl
      2. Adding a new style class
      3. Using the new CSS property
    7. Summary
  13. Building a Dynamic UI
    1. Tuning min and max size properties
    2. Controlling node location with AnchorPane
    3. Planning node size behavior with grow priorities
    4. Fluid layouts
    5. Enhancing applications with scrolling
    6. Summary
  14. Effects
    1. Applying basic effects
      1. Adding shadow effects
        1. Using DropShadow
        2. Using InnerShadow
        3. Understanding the base Shadow effect
      2. Adding reflections
      3. Combining effects
      4. Distorting using blur effects
    2. Adding color effects
      1. Using ColorAdjust
      2. Using ColorInput
      3. Using SepiaTone
      4. Bloom and Glow
    3. Applying lighting effects
      1. Understanding the types of light
        1. Using Distant light
        2. Using Spot light
        3. Using Point light
      2. Using BumpInput
    4. Transformation effects
      1. Setting up PerspectiveTransform
      2. Distorting an image with DisplacementMap
    5. Using blend effects
      1. Cutting out with the SRC_ATOP blend mode
      2. Calculating the difference between images
      3. Lightening and darkening
      4. Other blend modes
    6. Summary
  15. Media and WebView
    1. Working with web content
      1. Presenting web content with WebView
        1. Context menu
        2. Accessibility features
      2. Web engine
        1. Handling page loading progress with LoadWorker 
        2. Loading content and user interface callbacks
        3. Using Document Object Model
        4. Running JavaScript on a page
        5. Calling JavaFX code from JavaScript
    2. Incorporating media into a JavaFX application
      1. Adding audio clips
      2. Working with the MediaPlayer and Media classes
      3. Adding video through MediaView
    3. Summary
  16. Advanced Controls and Charts
    1. Advanced controls
      1. ListView
        1. Managing ListView items
        2. Using Selection and Focus API
        3. Editable lists
          1. Creating the TextFieldListCell
          2. Editing through a ChoiceBox/ComboBox
          3. Using CheckBox
        4. Creating custom cells
      2. Using TableView
        1. TableModel
        2. Creating and combining columns to form tables
        3. Sorting
        4. Observable Model
        5. Making a table editable
    2. Working with JavaFX charts
      1. Creating a Pie chart
      2. Creating a Line chart
      3. Review of other XY charts
    3. Custom controls
      1. Skins
      2. ClockControl demo
      3. Java 9 and 10 API for skins
    4. Summary
  17. Packaging with Java9 Jigsaw
    1. Handmaking JAR files
      1. Running the demo project
      2. Basic commands of the javapackager tool
    2. Creating self-contained applications
      1. Preparing OS-native installers with javapackager
    3. Working with Jigsaw modules
      1. Making our own module
    4. Summary
  18. 3D at a Glance
    1. Introduction to the JavaFX 3D API
      1. Basic 3D elements
      2. Adding Camera to the Scene
      3. Lighting the Scene
      4. Using Materials
        1. Using Bump Map
        2. Working with the Diffuse and Self-Illumination maps
    2. Summary
  19. What's Next?
    1. Other materials
      1. Official documentation of JavaFX
      3. Working with JavaFX source code
    2. Beyond the official API
      1. Frameworks and libraries
      2. Blogs
    3. Future of JavaFX
    4. Summary
  20. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Mastering JavaFX 10
  • Author(s): Sergey Grinev
  • Release date: May 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788293822