You are previewing JavaFX Rich Client Programming on the NetBeans Platform.
O'Reilly logo
JavaFX Rich Client Programming on the NetBeans Platform

Book Description

JavaFX is a state-of-the-art graphics toolkit that is now built into Java and can be easily integrated with the NetBeans Platform. With JavaFX, you can create advanced user interfaces, manipulate media, generate graphical effects and animations, and much more. The NetBeans Platform provides a framework for building robust, modular applications with long life expectancies. Together, JavaFX and the NetBeans Platform provide the basis for creating visually appealing, industrial-strength applications.

Focusing on JavaFX as the front end for rich client applications, this guide’s examples cover JavaFX 8 with the NetBeans Platform, NetBeans IDE, and Java 8. Gail and Paul Anderson fully explain JavaFX and its relationship with the NetBeans Platform architecture, and systematically show Java developers how to use them together effectively. Each concept and technique is supported by clearly written code examples, proven through extensive classroom teaching.

Coverage includes

  • Background basics with Java, JavaFX, and UI events

  • Building loosely coupled applications

  • NetBeans Platform Modules and Lookup

  • NetBeans Platform Nodes, Explorer Views, and Actions

  • Building CRUD-based applications

  • Integrating JavaFX with a Swing-based framework

  • Using JavaFX Charts with the NetBeans Platform

  • Using the NetBeans Platform File System and Data System

  • Keeping the UI responsive

  • Table of Contents

    1. About This eBook
    2. Title Page
    3. Copyright Page
    4. Contents
    5. Foreword
    6. Preface
      1. Our Approach
      2. About the Examples
      3. Notational Conventions
      4. Acknowledgments
    7. About the Authors
    8. 1. A Tour of the NetBeans Platform
      1. What You Will Learn
      2. 1.1 Background Basics
        1. JavaFX Integration
      3. 1.2 The NetBeans Platform: The Big Picture
        1. Module System API
        2. Lookup API
        3. Window System API
        4. File System API
        5. Nodes and Explorer Views
        6. But Wait . . . There’s More
      4. 1.3 FamilyTreeApp Reference Application
        1. FamilyTreeApp and JavaFX
        2. JavaFX 3D Integration Possibilities
      5. 1.4 Documentation
      6. 1.5 How to Get Java and the NetBeans Platform Software
      7. 1.6 Example Software Bundle
      8. 1.7 Key Point Summary
    9. 2. Background Basics
      1. What You Will Learn
      2. 2.1 JavaBeans and Properties
        1. Creating a Java Application
        2. Bound Properties
        3. Coarse-Grained Notification for JavaBean Objects
      3. 2.2 Lambda Expressions
        1. Lambda Expressions with Functional Interfaces
        2. Functional Data Structures
      4. 2.3 Swing Basics
        1. Creating a GUI-Form Project
        2. Swing Form Designer
        3. Program Structure
        4. Single-Threaded Model
        5. Java Logging Facility
        6. Using Swing Components
        7. Event Handlers and Loose Coupling
      5. 2.4 Improving the User Experience
      6. 2.5 Concurrency and Thread Safety
        1. Thread-Safe Objects
        2. Adding Listeners and Thread Safety
        3. Concurrency in Swing
      7. 2.6 Swing Background Tasks
        1. Introducing SwingWorker
        2. Monitoring SwingWorker Status
      8. 2.7 Key Point Summary
        1. What’s Next?
    10. 3. Introduction to JavaFX
      1. What You Will Learn
      2. 3.1 What Is JavaFX?
        1. A Bit of History
        2. The Scene Graph Metaphor
        3. Single-Threaded Model
      3. 3.2 Building JavaFX Programs
        1. Creating a JavaFX Application
        2. Java APIs
        3. Creating a JavaFX FXML Application
        4. CSS Files
        5. Animation
      4. 3.3 JavaFX Properties
        1. What Is a JavaFX Property?
        2. Using Listeners with Observable Properties
        3. Read-Only Properties
        4. Binding
      5. 3.4 Putting It All Together
      6. 3.5 Key Point Summary
        1. What’s Next?
    11. 4. Working with JavaFX
      1. What You Will Learn
      2. 4.1 Creating JavaFX Properties
        1. JavaFX Properties with Lazy Evaluation
        2. Object Properties
        3. Immutable Properties
        4. Computed Properties
        5. Methods equals() and hashCode()
      3. 4.2 Using JavaFX Properties in a JavaFX Application
        1. Creating a JavaFX FXML Application
      4. 4.3 Observable Collections
      5. 4.4 JavaFX Applications
        1. Program Structure
        2. Scene Builder and FXML
        3. JavaFX Controls
        4. JavaFX Controller Class
      6. 4.5 Concurrency and Thread Safety
        1. Concurrency in JavaFX
        2. Observable Properties and Thread Safety
      7. 4.6 JavaFX Background Tasks
        1. Worker and Task
        2. ProgressIndicator
      8. 4.7 Monitoring Background Tasks
        1. Using Method updateValue()
        2. Updating a Read-Only JavaFX Property
        3. Updating the JavaFX Scene Graph from a Background Task
      9. 4.8 Key Point Summary
    12. 5. A Taste of Modularity
      1. What You Will Learn
      2. 5.1 Modular Architecture
        1. Modules
        2. NetBeans Runtime Container
      3. 5.2 Creating a NetBeans Platform Application
        1. NetBeans Platform Project
      4. 5.3 Creating Modules
        1. Creating a NetBeans Module
        2. Creating Additional Modules
      5. 5.4 Configuring a Module with Public Packages
      6. 5.5 Registering a Service Provider
        1. Global Lookup
      7. 5.6 Configuring a Window for Selection
        1. Porting Swing UI Code to a TopComponent
        2. Lookup API
        3. Configuring the TopComponent
      8. 5.7 Configuring a Window with Form Editing
        1. Set Module Dependency
        2. Create a Window
        3. Configure PersonEditorTopComponent UI
        4. Add Code to PersonEditorTopComponent
        5. Configure TopComponent Life Cycle Methods
        6. Another Look at Lookup
      9. 5.8 Module Life Cycle Annotations
        1. Using @OnStart
        2. Using @OnStop
      10. 5.9 What We Know So Far
      11. 5.10 Key Point Summary
        1. What’s Next?
    13. 6. JavaFX Integration
      1. What You Will Learn
      2. 6.1 JavaFX and the NetBeans Platform
        1. Java 8 and JavaFX 8 Enhancements
        2. Create a NetBeans Platform Application
        3. Create a NetBeans Module
        4. Add a Window to the Module
        5. Add JavaFX Content to the TopComponent
        6. The Magic of JFXPanel
        7. SwingNode
      3. 6.2 Communication Strategies
        1. Accessing the JavaFX Controller Instance
      4. 6.3 Integrating with the NetBeans Platform
        1. Create a NetBeans Platform Application
        2. Create NetBeans Platform Modules
        3. Configure a Module with Public Packages
        4. Register a Service Provider
        5. Configure a Window with JavaFX for Selection
        6. Configure a Window with JavaFX for Form Editing
      5. 6.4 Key Point Summary
    14. 7. Nodes and Explorer Views
      1. What You Will Learn
      2. 7.1 The NetBeans Model View Controller
      3. 7.2 Nodes
        1. NodeListener and PropertyChangeListener
        2. Building a Node Hierarchy
        3. Displaying the Node Hierarchy
        4. A Multi-Level Node Hierarchy
        5. Using BeanNode
        6. Creating Your Own Property Sheet
        7. Using FilterNode
      4. 7.3 Explorer Views
        1. Quick Search
        2. BeanTreeView
        3. OutlineView
        4. Master-Detail View
        5. PropertySheetView
      5. 7.4 Creating a Selection History Feature
        1. Modify PersonNode PropertySheet
        2. Modify OutlineView in GenderTopComponent
        3. Add Features to Your Application
      6. 7.5 Key Point Summary
    15. 8. NetBeans Platform Window System
      1. What You Will Learn
      2. 8.1 Window Framework Overview
        1. Window Layout
        2. Window Modes
        3. TopComponents
        4. Window Operations
        5. Limiting the Window System’s Behavior
        6. Window Switching
        7. Window Tab Customization
        8. Window Manager
      3. 8.2 TopComponent Basics
        1. TopComponent Java Code
        2. Window Header Animated Notifications
      4. 8.3 TopComponent Persistence
        1. Windows2Local Folder
      5. 8.4 TopComponent Client Properties
      6. 8.5 Creating Non-Singleton TopComponents
        1. Opening Windows from User Code
      7. 8.6 Window System Life Cycle Management
        1. Using the Window Manager
        2. Using @OnShowing
      8. 8.7 TopComponent Modes
      9. 8.8 Window Groups
        1. Window Group Example
      10. 8.9 Window Layout
        1. Creating TopComponents
        2. A View-Only Window Layout
      11. 8.10 Window Layout Roles
        1. RoleExample Application and Role-Based TopComponents
        2. Credential Checking and Role Assignments
        3. LoginTopComponent
      12. 8.11 Key Point Summary
    16. 9. Action Framework
      1. What You Will Learn
      2. 9.1 Type of Actions
        1. Always-Enabled Actions
      3. 9.2 Actions and Lookup
        1. Callback Actions
        2. Context-Aware Actions
      4. 9.3 Editing the Node Hierarchy
        1. Group Window Node Actions
        2. Reorder and Index.Support
        3. Implementing Drag and Drop
        4. Implementing Cut, Copy, Paste, Delete
      5. 9.4 Inter-Window Drag and Drop
        1. Trash Window Node Actions
        2. Implementing Drag and Drop Delete
      6. 9.5 Key Point Summary
    17. 10. Building a CRUD Application
      1. What You Will Learn
      2. 10.1 Create-Read-Update-Delete Application
        1. Defining Capabilities
        2. Implementing Read
        3. Implementing Delete
        4. Implementing Create
        5. Implementing Update
      3. 10.2 Using CRUD with a Database
        1. Create Wrapped Libraries
        2. JavaDB Server and Database
        3. Implement FamilyTreeManager
      4. 10.3 Concurrency in the FamilyTreeApp Application
        1. Concurrency with Read
        2. Concurrency with Delete and Create
        3. Concurrency with Update
      5. 10.4 Key Point Summary
    18. 11. Dialogs
      1. What You Will Learn
      2. 11.1 Dialog Overview
      3. 11.2 Standard Dialogs
        1. NotifyDescriptor.Message
        2. NotifyDescriptor.Confirmation
        3. NotifyDescriptor.InputLine
      4. 11.3 Customizing Standard Dialogs
      5. 11.4 Custom Dialogs
        1. Error Handling
      6. 11.5 Custom Login Dialog
      7. 11.6 Putting It All Together
        1. RoleExample Application
      8. 11.7 Key Point Summary
    19. 12. Wizards
      1. What You Will Learn
      2. 12.1 Wizard Overview
      3. 12.2 The Wizard Wizard
        1. A Bare-Bones Wizard
        2. Registering a Wizard’s Action
      4. 12.3 Wizard Input
      5. 12.4 Wizard Validation
        1. Coordinating Input with Other Panel Wizards
        2. Visual Panel Updates
      6. 12.5 Simple Validation API
        1. Prepare to Use the Validation Library
        2. Using the Simple Validation API Library
        3. Using a Custom Validator
      7. 12.6 Finishing Early Option
      8. 12.7 Asynchronous Validation
      9. 12.8 Dynamic Sequence Wizards
        1. Building the Dynamic Step Wizard
        2. The PizzaWizardIterator
        3. IdentifyCustomer Panel
        4. BuildPizza Panel
        5. Create the OrderPizzaAction
      10. 12.9 Wizard Instantiating Iterators
        1. WizardDescriptor.InstantiatingIterator
        2. WizardDescriptor.AsynchronousInstantiatingIterator
        3. WizardDescriptor.ProgressInstantiatingIterator
        4. WizardDescriptor.BackgroundInstantiatingIterator
      11. 12.10 Key Point Summary
    20. 13. File System
      1. What You Will Learn
      2. 13.1 File System API
      3. 13.2 The File System API Overview
        1. Exploring the FileSystem API
        2. The Output Window
        3. Create a Folder
        4. Get or Create a File in a Folder
        5. Write to and Read from Files
        6. Rename and Delete Files
        7. File System API Useful Methods
      4. 13.3 Monitoring File Changes
        1. FileObject Attributes
        2. Favorites Window
        3. Implementing the FileChangeListener
      5. 13.4 Including a File with Your Application
        1. Create Module AppConfigFile
        2. Install a File in a Module
        3. Using the InstalledFileLocator Service
        4. Installing an NBM in NetBeans IDE
      6. 13.5 The Layer File and System FileSystem
        1. Layer Files and Configuration
        2. Exploring the System FileSystem
        3. Using the Layer File for Inter-Module Communication
      7. 13.6 Key Point Summary
    21. 14. Data System
      1. What You Will Learn
      2. 14.1 Data System API Overview
        1. FileObject, DataObject, and Node
        2. FileObject MIME Type and Lookup
        3. DataObject Factory and DataObject Lookup
        4. Accessing FileObjects from DataObjects
        5. DataObjects and Nodes
        6. Using DataNode and Lookup
      3. 14.2 Creating a New File Type
        1. Create a NetBeans Platform Application and Module
        2. Add the Favorites and Templates Modules
        3. Create a New File Type
        4. Create and Edit a New FTR File
        5. Provide Child Nodes Based on Content
      4. 14.3 Working with MultiView Windows
        1. Using the Visual Library
        2. Using JavaFX
      5. 14.4 Creating an XML-Based File Type
        1. Create a NetBeans Platform Application and Module
        2. Add the Favorites and Templates Modules
        3. Create a New XML File Type
        4. Add the XML Text Editor
        5. Add JavaFX Content
      6. 14.5 Key Point Summary
    22. 15. JavaFX Charts
      1. What You Will Learn
      2. 15.1 JavaFX Charts and the NetBeans Platform
        1. Application Overview
        2. Working with AbstractTableModel
        3. Working with Swing JTable
        4. Integrating JavaFX Charts
      3. 15.2 Introducing JavaFX Charts
        1. JavaFX Chart Overview
      4. 15.3 Data Visualization with JavaFX Charts
        1. Line Chart
        2. Scatter Chart
        3. Bar Chart
        4. Area Chart
        5. Stacked Area Chart
        6. Stacked Bar Chart
        7. Bubble Chart
        8. Pie Chart
      5. 15.4 Adding Behaviors to JavaFX Charts
        1. Accessing JavaFX Chart Nodes
        2. Adding PieChart Features
      6. 15.5 Saving Charts
        1. ChartSaveCapability
        2. ChartSaveAction
        3. FileChooserBuilder
        4. BufferedImage
        5. Implementing the ChartSaveCapability
      7. 15.6 Key Point Summary
    23. 16. Using Web Services
      1. What You Will Learn
      2. 16.1 RESTful Web Services and the NetBeans Platform
      3. 16.2 Creating RESTful Web Services
        1. Create Database
        2. Create RESTful Web Service Application
        3. RESTful Services from Database
        4. Entity Classes and JavaFX Properties
        5. Test the Web Services
      4. 16.3 A Java Application Web Service Client
        1. Create Java Application
        2. Add RESTful Java Client
        3. Add JAR Files to Project
        4. Add Client Code to Main Program
      5. 16.4 RESTful Web Services in a NetBeans Platform Application
        1. Create a NetBeans Platform Application and Module
        2. Generate RESTful Web Service Clients
        3. Application Overview
        4. Using JavaFX Services
        5. Implementing a RESTful Client Service Provider
        6. JavaFX TableView
        7. JavaFX Chart Module
      6. 16.5 Key Point Summary
    24. 17. Branding, Distribution, and Internationalization
      1. What You Will Learn
      2. 17.1 What Is Branding?
        1. Using the Branding Menu
        2. Customizing the Application Title
        3. Customizing the Splash Screen
      3. 17.2 Application Updates
        1. Enable Updates of Your Application
        2. Create an Update Center
        3. Dynamically Uninstall a Module (Plugin)
        4. Adding Modules to an Application
        5. Install a Plugin
      4. 17.3 Application Distribution
        1. Create an Installer
        2. Installing the Application
        3. Customizing the Installer Images
      5. 17.4 Application Internationalization
        1. Internationalization and Java
        2. Internationalization and the NetBeans Platform
        3. Number Formatting
        4. Editing Properties Files
        5. Internationalization and JavaFX
        6. Testing Target Locales
        7. NetBeans Platform Application Internationalization
        8. Customizing Resource Bundles
      6. 17.5 Key Point Summary
    25. Index