You are previewing JavaFX 1.2 Application Development Cookbook.
O'Reilly logo
JavaFX 1.2 Application Development Cookbook

Book Description

Over 60 recipes to create rich Internet applications with many exciting features

  • Easily develop feature-rich internet applications to interact with the user using various built-in components of JavaFX

  • Make your application visually appealing by using various JavaFX classes—ListView, Slider, ProgressBar—to display your content and enhance its look with the help of CSS styling

  • Enhance the look and feel of your application by embedding multimedia components such as images, audio, and video

  • Part of Packt's Cookbook series: Each recipe is a carefully organized sequence of instructions to complete the task as efficiently as possible

In Detail

JavaFX Script enables you to easily create rich Internet applications by embedding multimedia components. Although you can create stylish Internet applications by modifying these default components, even advanced users find it challenging to create impressive feature-rich Internet applications with JavaFX. Also, there are limited JavaFX components to work with and by default these components don't look visually appealing.

This book explores limitless possibilities to style your application by coding JavaFX components to display your content in a more appealing fashion. The recipes in this book will help you to create customized JavaFX components with which you can make modern, feature-rich applications.

First, you will be introduced to the JavaFX SDK and other development tools available to help you be productive during development. You will create an application in JavaFX by arranging complex graphical components (and non-graphical libraries) with simplified declarative constructs. You will then explore the fun side of JavaFX by using transformation techniques to manipulate the location and dimensions of objects. The next chapter is about the GUI components that are available in the framework, which provide a high level of interactivity. You will learn how to use the media component to play media content. Then we will access data and manipulate data locally or remotely. You will explore many deployment options and integration tips and tricks to take advantage of runtime contexts. Finally, you will interact with pure Java code to read and write files in JavaFX and to establish interactions with computing platforms.

Get quick solutions to create modern rich Internet applications using the various JavaFX features ranging from JavaScript fundamentals to more complicated topics including visual controls, custom components, multimedia, animation, effects, web and data services, deployment practices, and much more

Table of Contents

  1. JavaFX 1.2 Application Development Cookbook
    1. Table of Contents
    2. JavaFX 1.2 Application Development Cookbook
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Errata
        2. Piracy
        3. Questions
    7. 1. Getting Started with JavaFX
      1. Introduction
        1. The Java proposition
        2. Enter JavaFX
      2. Installing the JavaFX SDK
        1. Getting ready
          1. Minimum system requirements
        2. How to do it...
          1. Installation on Windows
          2. Installation on Mac OS
          3. Installation on Ubuntu Linux and OpenSolaris
        3. How it works...
      3. Setting up JavaFX for the NetBeans IDE
        1. Getting ready
        2. How to do it...
          1. NetBeans installation on Windows
          2. Installation on Mac OS
          3. Installation on Ubuntu Linux and OpenSolaris
        3. How it works...
        4. There's more...
          1. Download JavaFX NetBeans plugin
        5. See also
      4. Setting up JavaFX for the Eclipse IDE
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Using javafxc to compile JavaFX code
        1. Getting ready
        2. How to do it...
        3. How it works...
          1. See also
      6. Creating and using JavaFX classes
        1. Getting ready
        2. How to do it...
          1. How it works...
            1. Object literal initialization
          2. There's more...
            1. Initialization block
          3. See also
      7. Creating and using variables in JavaFX
        1. Getting ready
        2. How to do it...
        3. How it works…
        4. There's more...
          1. Explicit type declaration
          2. Implicit coercion
          3. JavaFX types
          4. Variable scope
            1. Script level
            2. Instance level
            3. Local level
        5. See also
      8. Using binding and triggers to update variables
        1. Getting ready
        2. How to do it...
        3. How it works...
          1. Binding to variables
          2. Binding to a conditional
          3. Binding to a code block
          4. Binding to a function
          5. Bind to an object literal
        4. There's more...
          1. Using triggers
        5. See also
      9. Creating and using JavaFX functions
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Bound functions
          2. The run() function
        5. See also
      10. Integrating your JavaFX code with Java
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There is more...
          1. Implementing a Java interface in JavaFX
        5. See also
      11. Creating and using JavaFX sequences
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There is more...
          1. Sequence operators
          2. Sequence operations
          3. Sequence slices
          4. Sequence loop query
      12. Working with JavaFX String
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There is more...
          1. Using JavaFX localization
    8. 2. Creating JavaFX Applications
      1. Introduction
      2. Building a JavaFX application
        1. Getting ready
        2. How to do it...
        3. How it works...
          1. Decomposing the application
        4. See also
      3. Drawing simple shapes
        1. Getting ready
        2. How to do it...
        3. How it works...
          1. There's more...
            1. Polyline and Polygon
            2. Arc
            3. Bézier curves
          2. See also
      4. Creating complex shapes using Path
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Creating shapes with constructive area geometry
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      6. Drawing letter shapes using the Text class
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Text origin
          2. Text wrapping
          3. Text alignment
          4. Embolden your font
          5. Locating fonts
        5. See also
      7. Handling user input
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      8. Arranging your nodes on stage
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      9. Making your scripts modular
        1. Getting ready
        2. How to do it...
          1. How it works...
          2. There's more...
            1. Script versus module
            2. Organize your code into packages
            3. Access modifiers
          3. See also
      10. Creating your own custom node
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      11. Controlling your application's window style
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Controlling opacity
        5. See also
      12. Going full-screen
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
    9. 3. Transformations, Animations, and Effects
      1. Introduction
        1. The JavaFX animation framework
      2. Modifying shapes with the Transformation API
        1. Getting started
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      3. Creating simple animation with the Transition API
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. The Timeline
        5. See also
      4. Composing animation with the Transition API
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      5. Building animation with the KeyFrame API
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Interpolation
          2. Using the Timeline class as a timer
        5. See also
      6. Creating custom interpolators for animation
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      7. Morphing shapes with the DelegateShape class
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Using data binding to drive animation sequences
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      9. Applying cool paint effects with gradients
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      10. Creating your own customized Paint
        1. Getting ready
        2. How to do it…
        3. How it works...
        4. See also
      11. Adding depth with lighting and shadow effects
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      12. Creating your own Text effect
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      13. Adding visual appeal with the Reflection effect
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
    10. 4. Components and Skinning
      1. Introduction
      2. Creating a form with JavaFX controls
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      3. Displaying data with the ListView control
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Using a custom data model with ListView
        5. See also
      4. Using the Slider control to input numeric values
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Showing progress with the progress controls
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      6. Creating a custom JavaFX control
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      7. Embedding Swing components in JavaFX
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Wrapping custom Swing controls into JavaFX node
          2. Creating a Swing control façade from JavaFX
        5. See also
      8. Styling your applications with CSS
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. JavaFX CSS
          2. Styling Text nodes with CSS
          3. Styling Paint properties with CSS
        5. See also
      9. Using CSS files to apply styles
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Pseudo-classes
          2. Cascading styles
        5. See also
      10. Skinning applications with multiple CSS files
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
    11. 5. JavaFX Media
      1. Introduction
      2. Accessing media assets
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      3. Loading and displaying images with ImageView
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Format support
          2. Asynchronous loading issues
          3. Image resize and aspect ratio
        5. See also
      4. Applying effects and transformations to images
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Creating image effects with blending
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      6. Playing audio with MediaPlayer
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      7. Playing video with MediaView
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      8. Creating a media playback component
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
    12. 6. Working with Data
      1. Introduction
        1. Storage API
        2. REST-style development
        3. Data visualization
      2. Saving data locally with the Storage API
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Storage organization
          2. Local storage configuration
      3. Accessing remote data with HttpRequest
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. HTTP methods
        5. See also
      4. Downloading images with HttpRequest
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      5. Posting data to remote servers with HttpRequest
        1. Getting ready
        2. How to do it...
        3. How it works...
          1. There's more...
          2. See also
      6. Uploading files to servers with HttpRequest
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      7. Building RESTful clients with the PullParser API
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Custom parsing
        5. See also
      8. Using the Feed API to create RSS/Atom clients
        1. Getting ready
        2. How to do it...
        3. How it works...
          1. There's more...
            1. Handling RSS
            2. Handling Atom
            3. Override default parsing behavior
          2. See also
      9. Visualizing data with the JavaFX chart API
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Chart customization
    13. 7. Deployment and Integration
      1. Introduction
        1. The unified programming model
      2. Building and packaging your app with an IDE
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      3. Building and packaging your app with javafxpackager
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Automating your JavaFX build with Ant
        5. See also
      4. Packaging your app to be Web Start(ed)
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      5. Packaging your app as an applet
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Overriding the JNLP file name
        5. See also
      6. Passing arguments to JavaFX applications
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Accessing all arguments
          2. Command-line arguments
          3. JVM arguments
        5. See also
      7. Making your applets drag-to-install
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. AppletStageExtension Hooks
          2. Preventing unintentional dragging
          3. Control post-installation behavior
        5. See also
      8. Controlling JavaFX applets from JavaScript
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Type crossing JavaScript to JavaFX
          2. Accessing the Scene graph
          3. Accessing JavaScript from JavaFX
        5. See also
    14. 8. The JavaFX Production Suite
      1. Introduction
      2. Loading multiple images dynamically
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      3. Exporting Adobe Photoshop graphics to JavaFX
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. The FXD data file
          2. What gets exported
      4. Exporting Adobe Illustrator graphics to JavaFX
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. What gets exported
        5. See also
      5. Exporting Scalable Vector Graphics (SVG) to JavaFX
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. What gets exported
          2. Features not supported
          3. Inkscape and JavaFX
        5. See also
      6. Using objects loaded from FXZ files
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Using FXDNode to load objects
            1. Accessing Group nodes directly
            2. Accessing objects directly
            3. Placing non-orphaned nodes
          2. Using FXDNode to load object asynchronously
            1. Event notifications through FXDLoader
        5. See also
    15. A. Mobile JavaFX
    16. B. JavaFX Composer
    17. C. JavaFX Products and Frameworks
    18. D. Best Practices for Development
    19. E. Best Practices for Deployment
    20. Index