1. Trang chủ
  2. » Công Nghệ Thông Tin

Pro JavaFX2 potx

636 6.2K 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Cover

    • Contents at a Glance

    • Contents

    • Foreword

    • About the Authors

    • About the Technical Reviewer

    • Acknowledgments

  • Getting a Jump Start in JavaFX

    • JavaFX Can’t Bring Rich-Client Java Back by Itself

    • A Brief History of JavaFX

    • Going to the Source: Oracle’s JavaFX Web Site

    • Accessing the JavaFX SDK API

    • Obtaining the JavaFX SDK

    • Other Available Tools

    • Developing Your First JavaFX Program: “Hello Earthrise”

    • Compiling and Running from the Command-Line

    • Understanding the Hello Earthrise Program

      • Building and Running the Program with NetBeans

    • Developing Your Second JavaFX Program: “More Cowbell!”

      • Building and Running the Audio Configuration Program

      • The Behavior of the Audio Configuration Program

      • Understanding the Audio Configuration Program

        • Creating an Instance of the Model, and the Magic of Binding

      • Colors and Gradients

      • The Model Class for the Audio Configuration Example

      • Defining Change Listeners in the Model class

    • Surveying JavaFX Features

    • Summary

    • Resources

  • Creating a User Interface in JavaFX

    • Introduction to Node-Centric UIs

    • Setting the Stage

      • Understanding the Stage Class

      • Using the Stage Class: The StageCoach Example

      • Understanding the StageCoach Program

        • Obtaining Program Arguments

        • Setting the Style of the Stage

        • Controlling Whether a Stage Is Resizable

        • Making a Stage Full Screen

        • Working with the Bounds of the Stage

        • Drawing Rounded Rectangles

        • Dragging the Stage on the Desktop When a Title Bar Isn’t Available

        • Using UI Layout Containers

        • Ascertaining Whether the Stage Is in Focus

        • Controlling the Z-Order of the Stage

        • Closing the Stage and Detecting When It Is closed

    • Making a Scene

      • Using the Scene Class: The OnTheScene Example

      • Understanding the OnTheScene Program

        • Setting the Cursor for the Scene

        • Painting the Scene’s Background

        • Populating the Scene with Nodes

        • Finding a Scene Node by ID

        • Accessing the Stage from the Scene

        • Inserting a Node into the Scene’s Content Sequence

        • CSS Styling the Nodes in a Scene

    • Handling Input Events

      • Surveying Mouse and Keyboard Events and Handlers

      • Understanding the KeyEvent Class

      • Understanding the MouseEvent Class

    • Animating Nodes in the Scene

      • Using a Timeline for Animation

        • The Metronome1 Example

        • Understanding the Metronome1 program

        • Understanding the Timeline Class

        • Inserting Key Frames into the Timeline

        • Controlling and Monitoring the Timeline

      • Using the Transition Classes for Animation

        • The MetronomeTransition Example

        • The Behavior of the MetronomeTransition Program

        • Understanding the MetronomeTransition Program

        • Using the TranslateTransition Class

        • Controlling and Monitoring the Transition

        • The MetronomePathTransition Example

        • The Behavior of the MetronomePathTransition Program

        • Understanding the MetronomePathTransition Program

        • Using the PathTransition Class

        • Drawing an Ellipse

      • The Zen of Node Collision Detection

        • Understanding the ZenPong Program

        • Using the KeyFrame Action Event Handler

        • Using the Node intersects() Method to Detect Collisions

        • Dragging a Node

        • Giving Keyboard Input Focus to a Node

        • Using the onKeyPressed Event Handler

    • Summary

    • Resources

  • Properties and Bindings

    • Forerunners of JavaFX 2.0 Binding

    • A Motivating Example

    • Understanding Key Interfaces and Concepts

      • Understanding the Observable Interface

      • Understanding the ObservableValue Interface

      • Understanding the WritableValue Interface

      • Understanding the ReadOnlyProperty Interface

      • Understanding the Property Interface

      • Understanding the Binding Interface

    • Type-Specific Specializations of Key Interfaces

      • A Common Theme for Type-Specific Interfaces

      • Commonly Used Classes

    • Creating Bindings

      • Understanding the Bindings Utility Class

      • Understanding the Fluent Interface API

    • Understanding the JavaFX Beans Convention

      • The JavaFX Beans Specification

      • Understanding the Eagerly Instantiated Properties Strategy

      • Understanding the Lazily Instantiated Properties Strategy

      • Using Selection Bindings

    • Summary

    • Resources

  • Building Dynamic UI Layouts in JavaFX

    • Introducing JavaFX Reversi

      • Board Layout and Basic Rules

      • Building a JavaFX Model for Reversi

    • Dynamic Layout Techniques

      • Centering Text Using Bind

      • Centering Revisited Using a StackPane

      • Aligning to Edges Using StackPanes and TilePanes

      • Using FlowPane and Boxes for Directional Alignment

      • Composing a Layout Using BorderPane

    • Creating Custom Regions

      • Building a Custom Square Region

      • Building a Resizable Reversi Piece

    • Laying Out the Tiles Using a GridPane

    • Aligning and Stretching with AnchorPane

    • When to Use Different Layouts

    • A New Perspective on Reversi: The JavaFX 3D Scene Graph

    • Bringing Reversi to Life

      • Highlighting Legal Moves

      • Highlighting the Active Cell

      • Taking Turns

      • Additional Game Enhancements

    • Summary

    • Resources

  • Using the JavaFX UI Controls

    • Trying Out the JavaFX UI Controls

    • Leveraging the JavaFX UI Controls

      • Setting the Stage for the StarterApp Program

      • Creating a Menu and Defining Menu Items

      • Creating a Toolbar

        • Defining Graphical Buttons

        • Defining Toggle Buttons

        • Using Toggle Groups

        • Inserting a Separator into a Toolbar

      • Creating a TabPane and Defining Tabs

      • Creating a TableView

        • Assigning Items to a Table

        • Defining TableView Columns

        • Detecting When a Row Is Selected

      • Creating an Accordion and Defining a TitledPane

      • Creating a TreeView

        • Defining a TreeItem

        • Detecting When a TreeItem Is Selected

      • Creating a ListView and Assigning Items to a ListView

      • Creating a SplitPane

      • Defining a ScrollPane

      • Using a CheckBox

      • Defining a RadioButton

      • Creating a Hyperlink

      • Defining a ChoiceBox

      • Using a MenuButton

      • Creating a ContextMenu

      • Creating a SplitMenuButton

      • Defining a TextField

      • Using a PasswordField

      • Creating a TextArea

      • Creating a Slider

      • Defining a ProgressIndicator

      • Defining a ScrollBar

      • Using a ProgressBar

      • Creating an HTMLEditor

      • Creating a Popup

      • Using a WebView

    • Summary

    • Resources

  • Collections and Concurrency

    • Understanding Observable Collections

      • Understanding ObservableList

      • Handling Change Events in ListChangeListener

      • Understanding ObservableMap

      • Using Factory and Utility Methods from FXCollections

    • Using the JavaFX Concurrency Framework

      • Identifying the Threads in a JavaFX Application

      • Fixing Unresponsive UIs

      • Understanding the javafx.concurrent Framework

        • Understanding the Worker Interface

        • Understanding the Task<V> Abstract Class

        • Understanding the Service<V> Abstract Class

    • Embedding JavaFX Scenes in Swing and SWT Applications

    • Summary

    • Resources

  • Creating Charts in JavaFX

    • Structure of the JavaFX Chart API

    • Using the JavaFX PieChart

      • The Simple Example

      • Some Modifications

    • Using the XYChart

      • Using the ScatterChart

        • A Simple Implementation

        • Improving the Simple Implementation

      • Using the LineChart

      • Using the BarChart

      • Using the AreaChart

      • Using the BubbleChart

    • Summary

    • Resources

  • Using the Media Classes

    • The Foundation

    • Supported Media Formats

    • Working with Audio Clips

      • Controlling the Playback Parameters of an AudioClip

      • Constructing the Scene

      • AudioClip Wrap-Up

    • Working with Media

    • Playing Audio

      • Error Handling

      • Displaying Metadata

      • Loading Media

      • Controlling Playback

        • Laying Out the Player Controls

        • Creating Playback Controls

        • Seeking

        • Controlling Volume

        • Repetition

      • Audio Equalization

      • MediaPlayer Wrap-Up

    • Playing Video

      • Controlling the Size of a MediaView

      • MediaView and Effects

      • Using Markers

      • One Player, Multiple Views

      • Converting AudioPlayer into a VideoPlayer

    • Summary

  • Accessing Web Services

    • Front-end and Back-end Platforms

    • Merging JavaFX and Java Enterprise Modules in the Same Environment

    • Using JavaFX to Call Remote (Web) Services

      • SOAP

      • REST

        • Setting Up the Application

        • Using the Twitter API

        • Using External Libraries

    • Summary

  • JavaFX Languages and Markup

    • A Quick Comparison of Alternative Languages

      • Vanishing Circles in Java

      • Vanishing Circles in Alternative JVM Languages

    • Making Your JavaFX Groovy

      • Introduction to GroovyFX

      • Properties in GroovyFX

      • GroovyFX Binding

      • GroovyFX API Enhancements

        • Animation

        • Tables

        • Layouts

    • Scala and JavaFX

      • Getting Started with ScalaFX

      • ScalaFX Proxies and Implicit Conversions

      • JavaFX Properties in Scala

      • ScalaFX Bind APIs

      • API Enhancements

        • Closures

        • Layout Constraints

        • Animation

    • Visage, the JavaFX Language

      • Advantages of Using Visage

      • Getting Started with Visage

    • Constructing UIs with FXML Markup

      • Learning FXML by Example

      • Controlling FXML Applications

    • Summary

    • Resources

  • The Visage Language in Depth

    • An Overview of Visage

    • Variables, Values, and Their Types

      • Variable Names

      • Variable Types

    • Primitive Types

      • Boolean Type

        • Boolean Literals and the Default Value

        • Boolean Operators

        • The Backing Class of the Boolean Type

      • Integer Type

        • Integer Literals and the Default Value

        • Arithmetic Operators

        • The Backing Class of the Integer Type

      • Character Type

        • Sources of Character Values and the Default Value

        • Arithmetic Operations

        • The Backing Class of the Character Type

      • Byte, Short, and Long Types

        • Sources of Byte and Short Values, Long Literals, and the Default Values

        • Arithmetic Operations

        • The Backing Classes of the Byte, Short, and Long Types

      • Float and Number Types

        • Number Literals and the Default Value

        • Arithmetic Operations

        • The Backing Class of the Number Type

      • Double Types

        • Double Literals and the Default Value

        • The Backing Class of the Double Type

      • String Type

        • String Literals and the Default Value

        • String Expressions

        • The Backing Class of the String Type

      • Duration Type

        • Duration Literals and the Default Value

        • Arithmetic Operations Involving Durations

        • The Backing Class of the Duration Type

      • Length Type

        • Length Literals and the Default Value

        • Core Types of Length Literals

        • Length Arithmetic and Conversions

        • The Backing Class of the Length Type

      • Angle Type

        • Angle Literals and the Default Value

        • Angle Arithmetic and Conversions

        • The Backing Class of the Angle Type

      • Color Type

        • Color Literals and the Default Value

        • Color Arithmetic

        • The Backing Class of the Color Type

    • Working with Sequences

      • Sequence Types

      • Constructing Sequences Using Explicit Sequence Expressions

      • Constructing Numeric Sequences Using Range Expressions

      • Manipulating Sequences

        • Accessing the Size of a Sequence

        • Accessing an Element in a Sequence

        • Accessing a Slice of a Sequence

        • Accessing a Subset of a Sequence Through a Predicate

        • Reversing a Sequence

        • Inserting an Element into a Sequence

        • Inserting Another Sequence into a Sequence

        • Deleting Elements from a Sequence

        • Sequence Manipulation Example

      • Comprehending Sequences

      • Using Utility Functions in visage.util.Sequences

    • Visage Expressions

      • Expressions and Their Types

      • Block Expression

      • Precedence and Groupings

      • Expression Separator

      • Variable and Constant Declarations

      • Assignment Operator

      • Compound Assignment Operators

      • Relational Operators

      • While Expression

      • Revisiting the for Expression

      • If Expression

    • Object Literals

      • Classes and Objects

      • The Object Literal Expression

        • Initializing Instance Variables

        • Default Instance Variables

        • Declaring Constants and Variables

        • Overriding Instance Functions and Instance Variables

      • Manipulating Objects

        • Manipulating Object States

        • Invoking Instance Functions

      • Handling Nulls in Visage

      • Creating Java Objects with the new Operator

      • Making of a Declarative Syntax

    • Working with Data Bindings

      • Bind Expression

        • What Does the Data Binding Remember?

        • Binding to if Expressions

        • Binding to for Expressions

        • Binding to a Block

        • Binding to Function Invocation Expressions

        • Binding to Object Literal Expressions

      • Bidirectional Bindings and Lazy Bindings

    • Working with Functions

      • Function Definitions

        • Return Types

        • Parameters and Their Types

        • Function Bodies and the Return Expression

        • Function Body Scope

      • Overloaded Functions

        • Implicit Type Conversions

        • Resolving Overloaded Functions

      • Function Types and Anonymous Functions

        • More Details on Function Type Specifiers

        • More Details on Anonymous Function Expressions

        • More Details on Closures

      • Bound Functions

      • Handling Exceptions

        • The Call Stack

        • Throwing Exceptions

        • Handling Exceptions

    • Working with Classes

      • Class Definitions

        • Instance Variables

        • Declaring Default Instance Variables

        • Instance Functions

        • The this Expression

        • init Blocks

      • Creating Class Hierarchies

        • Mix-in Classes

        • Extending Classes

        • Overriding Instance Variables

        • Overriding Instance Functions

        • The super Keyword

        • Using Abstract and Mix-in Classes

        • Conflict Resolution in Mix-in Inheritance

        • Casting and the instanceof and as Operators

    • Organizing Visage Code

      • Scripts

      • Modules

      • A Special Provision for Classes

      • Packages

      • Import Directives

      • Access Modifiers

        • Protected Modifiers

        • public-init and public-read Modifiers

    • Triggers

      • Accessing the Old and New Values in Trigger Blocks

      • Accessing Sequence Modification Information in Trigger Blocks

      • Debugging with Triggers

    • String Formatting and Internationalization

      • Using String Format Specifications

      • Internationalizing Visage Programs

    • Leveraging Java from Visage

      • Instantiating Java Classes

      • Accessing Java Object Fields

      • Calling Java Methods

      • Accessing Static Fields and Methods

      • Quoting Visage Keywords

      • Accessing Nested Classes

      • Accessing Java Enums

      • Extending Java Classes and Interfaces

      • Dealing with Java Arrays

      • Iterating Through Java Collections

    • Visage Reflection

      • Mirror-Based Reflection

      • Entering the Reflection World

        • Programming Through Reflection

        • Getting and Setting Values of Instance and Script Variables

      • Invoking Instance and Script Functions

        • Other Reflection Capabilities

    • Resources

  • Index

    • A

    • B

    • C

    • E

    • F

    • G

    • H

    • I

    • J

    • K

    • L

    • M

    • O

    • S

    • T

    • U

    • V

    • W, X, Y, Z

Nội dung

[...]... in Listing 1-4 Listing 1-4 The Source Code for AudioConfigModel.java package projavafx.audioconfig.model; import import import import import import import import import javafx.beans.property.BooleanProperty; javafx.beans.property.IntegerProperty; javafx.beans.property.SimpleBooleanProperty; javafx.beans.property.SimpleIntegerProperty; javafx.beans.value.ChangeListener; javafx.beans.value.ObservableValue;... CONFIGURATION PROGRAM USING NETBEANS To build and execute this program using NetBeans, perform the following steps 1 From the File menu, select the Open Project menu item In the Open Project dialog box, navigate to the Chapter01 directory where you extracted the book’s code download bundle, as shown here: 2 Select the AudioConfig project in the pane on the left, and click the Open Project button 3 Run the project... Chapter01/HelloEarthRise/src/projavafx/helloearthrise/ui directory of this book’s source code download 10 Right-click on the HelloEarthrise project in the Projects pane and select Run Project from the context menu The HelloEarthRise program should begin executing, as you saw in Figure 1-4 earlier in the chapter At this point, you’ve built and run the “Hello Earthrise” program application, both from... Hello Earthrise program, perform the following steps 1 Start up NetBeans containing the JavaFX 2.0 plug-in 2 Choose File ➤ New Project from the menu bar The first window of the New Project Wizard will appear: 17 CHAPTER 1 ■ GETTING A JUMP START IN JAVAFX 3 18 Choose Java in the Categories pane and JavaFX Application in the Projects pane, and click the Next button The next page in the New Project Wizard... Cowbell” program Building and Running the Audio Configuration Program Earlier in the chapter, we showed you how to create a new JavaFX project in NetBeans, and how to add a folder that contains source code files to the project For this example (and the rest of the examples in the book), we take advantage of the fact that the code download bundle for the book contains both NetBeans and Eclipse project... type the project name (we used HelloEarthRise) and click the Browse button 5 On the Select Project Location screen, navigate to the directory in which you’d like to create this project (we used C:\MyJavaFX), and click the Open button 6 Select the Create Main Class check box, and change the supplied package/class name to: projavafx.helloearthrise.ui.HelloEarthRiseMain 7 Select the Set as Main Project... .code omitted textDb.textProperty().bind(acModel.selectedDBs.asString().concat(" dB")); slider.valueProperty().bindBidirectional(acModel.selectedDBs); As shown in this snippet, the text property of the Text object is bound to an expression The bind function contains an expression (that includes the selectedDBs property), which is evaluated and becomes the value of the text property Look at Figure 1-7... projavafx.helloearthrise.ui.HelloEarthRiseMain 7 Select the Set as Main Project check box 8 Click the Finish button The HelloEarthrise project with a default main class created by the JavaFX Plugin for NetBeans should now be created If you’d like to run this default program, right-click on the HelloEarthRise project in the Projects pane and select Run Project from the context menu 9 Enter the code from Listing 1-1 above into the HelloEarthRiseMain.java... CHAPTER 1 ■ GETTING A JUMP START IN JAVAFX items(acModel.genres) build() ) build() ) build(); textDb.textProperty().bind(acModel.selectedDBs.asString().concat(" dB")); slider.valueProperty().bindBidirectional(acModel.selectedDBs); slider.disableProperty().bind(acModel.muting); mutingCheckBox.selectedProperty().bindBidirectional(acModel.muting); acModel.genreSelectionModel = genreChoiceBox.getSelectionModel();... of a property (such as the height of a rectangle) to an expression Data binding is a major enabler of using declarative code In this example, some of the program is declarative in that it contains a large expression This expression begins by defining a Scene object with the SceneBuilder class Nested within that are properties of the Scene object, such as its width and height A Scene also has a property . first and the program will begin executing as soon as this takes place. • Java Auto-Updater: This provides a faster and more reliable process for updating. look at the properties available in the javafx.scene.Group class. Then look at the properties available in the javafx.scene.Node class properties, which

Ngày đăng: 14/03/2014, 09:20

Xem thêm

TỪ KHÓA LIÊN QUAN