You are previewing Beginning JavaFX™.
O'Reilly logo
Beginning JavaFX™

Book Description

The open source JavaFX platform offers a Java-based approach to rich Internet application (RIA) development—an alternative to Adobe Flash/Flex and Microsoft Silverlight. At over 100 million downloads, the new JavaFX 2.x is poised to be a significant player now.

Written by a JavaFX engineer and developer, this book is one of the first on the new JavaFX 2.x platform to give you the following:

  • The fundamentals of JavaFX scripting on desktop and mobile platforms

  • Examples of RIAs using JavaFX Graphics

  • Media and animation using JavaFX

  • See how JavaFX gives you dynamic Java effects in your RIA application development.

    Table of Contents

    1. Copyright
    2. About the Authors
    3. About the Technical Reviewer
    4. Acknowledgments
    5. Introduction
    6. 1. Introduction to RIA
      1. 1.1. The History of RIA
      2. 1.2. Key Characteristics of RIA
      3. 1.3. RIA Workflow
      4. 1.4. Why RIA
      5. 1.5. Some RIA Examples
      6. 1.6. Summary
    7. 2. Introduction to JavaFX
      1. 2.1. Why JavaFX
      2. 2.2. Advantages of JavaFX
      3. 2.3. History of JavaFX
      4. 2.4. The JavaFX Platform
        1. 2.4.1. The Developer Bundle
        2. 2.4.2. The Designer Bundle
        3. 2.4.3. Standalone
      5. 2.5. JavaFX Platform Integration: The Bigger Picture
      6. 2.6. JavaFX Mobile: An Introduction
        1. 2.6.1. Advantages of JavaFX Mobile
      7. 2.7. Deployment and Distribution
      8. 2.8. Getting Started
        1. 2.8.1. What to Download
      9. 2.9. Writing Your First JavaFX Application
        1. 2.9.1. Running Your Application Using NetBeans
          1. 2.9.1.1. Standalone Mode
          2. 2.9.1.2. Browser/Java Web Start Mode
          3. 2.9.1.3. Mobile Emulator
        2. 2.9.2. Running the Application from the Command Line
          1. 2.9.2.1. Compiling the Application for Standalone Execution
          2. 2.9.2.2. Compiling the Application for Browser/Java Web Start Execution with JavaFX Packager
          3. 2.9.2.3. Building and Running the Application Using JavaFX Packager for the DESKTOP Profile
          4. 2.9.2.4. Building and Running the Application Using JavaFXPackager for the MOBILE Profile
      10. 2.10. Comments
      11. 2.11. Summary
    8. 3. Data Types
      1. 3.1. Variable Declaration
      2. 3.2. var vs. def Declarations
        1. 3.2.1. Variable Naming
          1. 3.2.1.1. Reserved Keywords in JavaFX Script
        2. 3.2.2. Variable Declaration Syntax
        3. 3.2.3. Data Types
          1. 3.2.3.1. String
            1. 3.2.3.1.1. Escape Sequences
        4. 3.2.4. Integer
          1. 3.2.4.1. Decimal Number
          2. 3.2.4.2. Hexadecimal Number
          3. 3.2.4.3. Octal Number
        5. 3.2.5. Number
        6. 3.2.6. Boolean
        7. 3.2.7. Duration
      3. 3.3. Typecasting
      4. 3.4. Sequences
      5. 3.5. Default Values for Data Types
      6. 3.6. Summary
    9. 4. Operators and Expressions
      1. 4.1. The Assignment Operator
      2. 4.2. The as Operator
      3. 4.3. Arithmetic Operators
        1. 4.3.1. The Modulus or Remainder Operator
        2. 4.3.2. The Arithmetic Assignment Operator
        3. 4.3.3. Operator Precedence
        4. 4.3.4. Unary Operators
        5. 4.3.5. The Increment and Decrement Operators: ++ and --
        6. 4.3.6. The Unary + and − Operators
        7. 4.3.7. The not Operator
        8. 4.3.8. Relational Operators
        9. 4.3.9. Logical Operators
        10. 4.3.10. Range Expressions
        11. 4.3.11. Block Expressions
      4. 4.4. Looping Expressions
        1. 4.4.1. While Loops
      5. 4.5. Break Expressions
        1. 4.5.1. Continue Expressions
        2. 4.5.2. The if-else Expression
        3. 4.5.3. Exception Handling
        4. 4.5.4. The new Expression
        5. 4.5.5. Differentiating Expressions
      6. 4.6. Summary
    10. 5. Functions
      1. 5.1. How a Function Works
        1. 5.1.1. A Function with Neither an Argument nor a Return Value
        2. 5.1.2. A Function with Arguments but Without a Return Value
        3. 5.1.3. A Function Without an Argument but with a Return Value
        4. 5.1.4. A Function with Arguments and a Return Value
      2. 5.2. Variable Access within a Function
        1. 5.2.1. Script-Level Variables
        2. 5.2.2. Local Variables
      3. 5.3. Function Overloading
      4. 5.4. Recursive Functions
      5. 5.5. Anonymous Functions
      6. 5.6. The run() Function
        1. 5.6.1. Command-Line Arguments
      7. 5.7. Summary
    11. 6. Class Definitions
      1. 6.1. Classes and Objects
        1. 6.1.1. Classes
        2. 6.1.2. Objects
      2. 6.2. Features of OOP
        1. 6.2.1. Data Abstraction
        2. 6.2.2. Encapsulation
        3. 6.2.3. Inheritance
        4. 6.2.4. Polymorphism
      3. 6.3. The Class Definition
        1. 6.3.1. Creating Object Literals
        2. 6.3.2. Initializing Class Attributes within an Object Literal
        3. 6.3.3. Calling the Members of the Class
        4. 6.3.4. Assigning Default Values to Data Members
        5. 6.3.5. The init Block
          1. 6.3.5.1. Order of Instance Initialization
        6. 6.3.6. The postinit Block
      4. 6.4. Modifying Class Objects
      5. 6.5. Objects as Function Arguments
        1. 6.5.1. Non-Member Functions Accessing the Object
      6. 6.6. Static Members
        1. 6.6.1.
          1. 6.6.1.1. Function Overloading Within a Class
      7. 6.7. Sharing a Function Name Between Script-Level and Member Functions
      8. 6.8. Calling a Java Method That Is a JavaFX Reserved Word
      9. 6.9. The abstract Class
      10. 6.10. Summary
    12. 7. Access Specifiers
      1. 7.1. The Script—The .fx File
      2. 7.2. The Script-Private Access Specifier
      3. 7.3. Packages
        1. 7.3.1. Statics in JavaFX Script
        2. 7.3.2. The package Access Specifier
        3. 7.3.3. Package Access with Class Members
        4. 7.3.4. Honoring Access Specifiers for Java Classes
      4. 7.4. The protected Access Specifier
      5. 7.5. The public Access Specifier
        1. 7.5.1.
          1. 7.5.1.1. The Enforced run() Function Requirement
      6. 7.6. JavaFX Secondary Access Specifiers
        1. 7.6.1. public-read
        2. 7.6.2. public-init
        3. 7.6.3. Secondary Specifiers and def
      7. 7.7. Access Specifiers for Class Definitions
        1. 7.7.1. Script-private Classes
        2. 7.7.2. Package-accessible Classes
        3. 7.7.3. Protected Classes
        4. 7.7.4. Public Classes
      8. 7.8. Summary
    13. 8. Inheritance
      1. 8.1. The Order of Initialization of Data Members
      2. 8.2. Overriding Data Members
      3. 8.3. Use of the super Keyword
      4. 8.4. Mixin Classes
        1. 8.4.1. Creating a Subclass from Multiple Mixin Classes
        2. 8.4.2. The Order of Initialization in Multiple Inheritance
      5. 8.5. Abstract Classes
        1. 8.5.1. Using a JavaFX Class to Extend a Java Abstract Class
      6. 8.6. Anonymous Implementation of Java Interfaces
      7. 8.7. Summary
    14. 9. Data Binding
      1. 9.1. What Does Binding Mean?
      2. 9.2. Recalculation of Expressions
      3. 9.3. Binding with Conditional Expressions
      4. 9.4. Binding with for Expressions
      5. 9.5. Binding Block Expressions
      6. 9.6. Binding Functions
      7. 9.7. Bound Functions
      8. 9.8. Binding with Object Literals
      9. 9.9. Bidirectional Binding
      10. 9.10. Lazy vs. Eager Binding
      11. 9.11. Summary
    15. 10. Sequences
      1. 10.1. The sizeof Operator
      2. 10.2. Accessing the Elements of a Sequence
      3. 10.3. Nested Sequences
      4. 10.4. Creating a Sequence Using a Range Expression
      5. 10.5. Excluding the End Value in the Sequence
      6. 10.6. Sequence Slicing
      7. 10.7. Using a Predicate to Create a Subset of a Sequence
      8. 10.8. Working with Sequences
        1. 10.8.1. Inserting an Element into a Sequence
        2. 10.8.2. Deleting an Element from a Sequence
        3. 10.8.3. Reversing a Sequence
      9. 10.9. Sequences as Function Parameters
      10. 10.10. Binding with Sequences
      11. 10.11. javafx.util.Sequences Utility Functions
      12. 10.12. Summary
    16. 11. Triggers
      1. 11.1. Defining a Simple Trigger
      2. 11.2. A Trigger with Access to the Old Value
      3. 11.3. Using Triggers with bind
      4. 11.4. Implementing Binding Using Triggers
      5. 11.5. Validation Within the Trigger
      6. 11.6. Sequence Triggers
      7. 11.7. Nested Triggers
      8. 11.8. Summary
    17. 12. Introduction to JavaFX UI Elements
      1. 12.1. Rendering Model: Immediate Mode vs. Retained Mode Rendering
        1. 12.1.1. Scene Graph
        2. 12.1.2. Scene
        3. 12.1.3. Stage
      2. 12.2. Coordinate System
      3. 12.3. Graphical API Summary
      4. 12.4. Node – The Base UI Element
      5. 12.5. Geometries
        1. 12.5.1. Stroke vs. Fill
          1. 12.5.1.1. Stroke Attributes
      6. 12.6. Writing your First UI
      7. 12.7. Paints
        1. 12.7.1. Solid Colors
        2. 12.7.2. Gradients
          1. 12.7.2.1. Linear Gradient
          2. 12.7.2.2. Radial Gradient
      8. 12.8. Input Handling
        1. 12.8.1. Keyboard Input
          1. 12.8.1.1. JavaFX Focus Sub-system
        2. 12.8.2. Mouse Input
          1. 12.8.2.1. BlocksMouse
      9. 12.9. Text Rendering
      10. 12.10. Image Rendering
        1. 12.10.1. Loading an Image
        2. 12.10.2. Rendering an image
      11. 12.11. Transformations
        1. 12.11.1. Translation
        2. 12.11.2. Rotation
          1. 12.11.2.1. Custom Node
        3. 12.11.3. Scaling & Shear
      12. 12.12. Controls & Layouts
      13. 12.13. StyleSheets
      14. 12.14. Charts
      15. 12.15. Effects
      16. 12.16. Bounds
        1. 12.16.1. Bounds Class
        2. 12.16.2. Node Bounds Variables
      17. 12.17. Summary
    18. 13. Introduction to Animation
      1. 13.1. What is Animation?
      2. 13.2. Animation in JavaFX
        1. 13.2.1. Play, Pause, or Stop a Timeline
        2. 13.2.2. KeyFrame Attributes
          1. 13.2.2.1. KeyFrame.action
          2. 13.2.2.2. KeyFrame.canSkip
        3. 13.2.3. Simplified Syntax
        4. 13.2.4. Transitions
          1. 13.2.4.1. Path Transitions
          2. 13.2.4.2. Scale Transitions
          3. 13.2.4.3. Rotate Transitions
          4. 13.2.4.4. Translate Transitions
          5. 13.2.4.5. Fade Transitions
          6. 13.2.4.6. Parallel and Sequential Transitions
      3. 13.3. Summary