SlideShare a Scribd company logo
www.devoxx.com
www.devoxx.com
JavaFX™ 1.0 In Practice
Richard Bair

Jasper Potts

Martin Brehovsky

Sun Microsystems
www.devoxx.com
Overall Presentation Goal
Learn what JavaFX can do for you

(and your customers)
www.devoxx.com
Our qualifications
Richard, Jasper, and Martin are all on the JavaFX SDK
team

Martin lead the team responsible for the JavaFX
Production Suite

Richard is one of the API leads for JavaFX SDK

Jasper is one of the key engineers on the JavaFX SDK
4
www.devoxx.com
JavaFX is the new client stack for graphical Java
applications across all devices.
www.devoxx.com
Introduction to JavaFX

JavaFX Script

Scene Graph

Music and Movies

Animations and Transitions

Tool Support

Q & A
6
Agenda
www.devoxx.com
Common APIs across devices

Scales from small devices to powerful desktops

Brings rich media and graphical APIs to Java

Simplifies building graphical consumer and enterprise
applications
7
Introduction to JavaFX™
www.devoxx.com
Expression language

Declarative and Procedural

Integrates with Java

Loosely based on JavaScript
8
JavaFX Script
www.devoxx.com
DEMO
Hello World
www.devoxx.com
println(“Hello World”)
10
Hello World Code
www.devoxx.com
JavaFX Script source files are called “scripts”

Scripts which expose no public API may be “loose”

Everything* in JavaFX Script is an expression

All blocks are expressions and the last line is the result

The result of the println expression is null

The JavaFX String primitive is java.lang.String
11
Hello World Explained
www.devoxx.com
Boolean

Integer

Number

String

Duration

Primitives cannot be null*
12
Primitive Data Types
www.devoxx.com
var s = “Hello World”;

var s2 = ‘I can use single quotes too’;

var i = 10;

var s3 = “The number is {i}”;

var even = i mod 2 == 0;

var s4 = “The number is {if (even) then ‘even’ else ‘odd’}”;

var s5 = “The hex code for 1024 is {%x 1024}”;

var s6 = “You can declare multiline strings”

“Just like this. Notice no ‘+’ sign”;
13
Declaring Strings
www.devoxx.com
var d = 23s;

var d2 = 2.3ms;

var d3 = 25.5 * 1.13s;

var d4 = 5m;

var d5 = 10h;
14
Declaring Durations
www.devoxx.com
JavaFX has “Sequences”, not arrays

A Sequence is an immutable ordered list of non-null
elements

JavaFX supports sequence comprehensions

Sequences can be “sliced”

Sequences can optimize memory usage
15
Declaring Sequences
www.devoxx.com
// A sequence of all the positive non zero integers. This

// actually uses very little memory since the range is

// remembered, not the values (since sequences are

// immutable)

var ints = [1..java.lang.Integer.MAX_INT];

println(sizeof ints);

// creates a subsequence which contains all positive non

// zero even integers

var even = ints[n | n mod 2 == 0];

// a simple sequence of strings

var names = [“Jasper”, “Richard”, “Martin”];
16
Declaring Sequences
www.devoxx.com
// A sequence of one can omit the brackets

var names:String[] = “Richard”;

// Empty sequences are not null

var names:String[];

println(sizeof names); // prints 0

// elements are accessed by index

var names = [“Jasper”, “Richard”, “Martin”];

var martin = names[2];

// and you can populate a sequence using a for loop

var hellos = for (i in [1..3]) { “Hello #{i}” }
17
Declaring More Sequences
www.devoxx.com
// Inserting items into a sequence

var names:String[] = “Richard”;

insert “Jasper” into names;

// Inserting before a certain index

insert “Martin” before names[1];

// Inserting after a certain index

insert “Duke” after names[1];

// Deleting from the sequence

delete “Duke” from names;
18
Modifying Sequences
www.devoxx.com
+ - / *

++ --

*= /= += -=

and or not

= == !=

mod
19
Operators
www.devoxx.com
if ( booleanExpression) then a else b

if (booleanExpression) a else b

if (booleanExpression) { a } else { b }

while (booleanExpression) { ... }

for (i in sequence) { ... }

Can get index of item “i” by “indexof i”

break

continue
20
Flow Control
www.devoxx.com
if ( booleanExpression) then a else b

An if expression returns either “a” or “b” as the result

If “a” or “b” is a block, then it returns the last line of the
block that was selected by the if statement

While and For are expressions which return a sequence
filled with the result of the last line of the block
21
Flow Control Expressions
www.devoxx.com
name:type style syntax

Type inference

var for variables, def for definitions
22
Declaring Variables
www.devoxx.com
// I cannot be changed. I’m inferred to be a Number.

def pi = 3.141592;

// I can be changed. And I’ve been explicitly declared

// as a Number

var radius:Number = 7;

// same as above except by type inference it thinks it is an

// Integer

var radius2 = 7;
23
Declaring Variables
www.devoxx.com
name(args):type style syntax

Type inference

Must use keyword function

Must use keyword override when overriding a function

May be public, package, protected, or implicitly private

May be anonymous (ie: closure)
24
Declaring Functions
www.devoxx.com
// A private function which returns the min of the two args

function min(first:Number, second:Number):Number {

if (first <= second) then first else second

}

// a function variable and anonymous function declaration

// and function invocation

var onError:function(e:Exception):Void;

onError = function(e:Exception):Void {

e.printStackTrace();

}

onError(e);
25
Declaring Functions
www.devoxx.com
Classes extend classes or interfaces

Scope modifiers: public, protected, package

Implicitly “script private”

init { } and postinit { } blocks take place of Constructors

Functions and variables declared outside a class are static

Multiple classes may be defined in a single Script
26
Declaring Classes
www.devoxx.com
// This class extends a Java interface

public class FooModel extends TableModel { ... }

// This class defines two variables and a function

public class Location {

public var x:Number;

public var y:Number;

public function move(newX:Number, newY:Number):Void {

x = newX;

y = newY;

}

}

27
Declaring Classes
www.devoxx.com
Variables use scope modifiers for read & write access

public

protected

package

“script private” by default

Variables can have additional modifiers to modify write
access

public-read

public-init
28
Variable Scope Modifiers
www.devoxx.com
public class ImmutableFoo {

// This variable can be initialized by anyone, but

// modified only by this script

public-init var name:String;

}

public class ReadOnly extends {

public var x1:Number;

public var x2:Number;

// This variable can only be read by everyone, it cannot

// be initialized or mutated outside this script

public-read var distance:Number;

}
29
Variable Scope Modifiers
www.devoxx.com
Variables are initialized from base class to child class in
the order in which they are declared

Variables are only initialized once

init { } blocks are called after all variables in the class have
been initialized

Parent class init { } blocks are called before child init { }

postinit { } blocks are called after the init { } block

Parent class postinit { } blocks are called after child
postinit { } blocks
30
Class Initialization
www.devoxx.com
public class Parent {

public var name = “Richard”;

init {

println(“name is {name}”);

}

}

public class Child extends Parent {

override var name = “Luke”;

}
31
Variable Initialization Order
www.devoxx.com
// prints out “Richard”

var parent = Parent { };

// prints out “Luke”

var child = Child { };
32
Variable Initialization Order
www.devoxx.com
Variables can have on replace triggers to execute
procedural code when the bound variable is updated

Triggers execute in an undefined order

Variables can have multiple triggers

Triggers are fired for every set, including initialization
33
Triggers
www.devoxx.com
public class Location {

public var x:Number on replace {

println(“New X Value is {x}”);

}

public var y:Number on replace {

println(“New Y Value is {y}”);

}

}
34
Triggers
www.devoxx.com
bind is a way to tie the value of one variable to the value
of an expression

binding must be defined when the variable is initialized

bindings are statically compiled

bound variables cannot be set manually

use bind with inverse for bidirectional binding
35
Bind
www.devoxx.com
public class Distance extends {

public var x1:Number;

public var x2:Number;

// Whenever x2 or x1 changes, distance will be updated

// Binding can be used for invariants

public-read var distance:Number = bind x2 - x1;

}
36
Simple Binding Example
www.devoxx.com
Concise declarative syntax for object creation

Similar to JavaScript

Combine with binding for maximum effect

variable: initial-value

initial-value is an expression
37
Object Literals
www.devoxx.com
// creates a Rectangle

// x: 10 is not an assignment, it is an initialization!

var rect = Rectangle {

x: 10

y: 10

width: 100

height: 100

}
38
Object Literal
www.devoxx.com
// creates a Rectangle with a Color for its fill

var rect = Rectangle {

x: 10

y: 10

width: 100

height: 100

fill: Color {

red: 1

green: 0

blue: 0

}

}
39
Nesting Object Literals
www.devoxx.com
// Notice that I can declare a var and use it in the literal

var rect = Rectangle {

var color = Color {

red: 1

green: 0

blue: 0

}

x: 10

y: 10

width: 100

height: 100

fill: color

}
40
Vars in Object Literals
www.devoxx.com
// A variation that allows me to reference the color later

var color:Color;

var rect = Rectangle {

x: 10

y: 10

width: 100

height: 100

fill: color = Color {

red: 1

green: 0

blue: 0

}

}
41
Vars in Object Literals
www.devoxx.com
// Here I’ll choose the color to use based on some boolean

var highContrast = false;

var rect = Rectangle {

x: 10

y: 10

width: 100

height: 100

fill: bind if (highContrast) then BLACK else GRAY

}

highContrast = true;
42
Object Literal With If
www.devoxx.com
Describes the graphics and controls in a scene

Each node in the graph has a single parent

Special “group” nodes have zero or more children

“leaf” nodes have no children

Graph is set on a Scene

Scene is set in a Stage
43
Scene Graph
www.devoxx.com44
Scene Graph
Leaf
Group
Group
Leaf Leaf
www.devoxx.com45
Scene Graph
Image
Group
Group
Circle Line
www.devoxx.com
Canvas upon which the Scene Graph is displayed

Can set multiple CSS Stylesheets

Can set background color (or set to null)

Can set canvas width / height
46
Scene
www.devoxx.com
DEMO
Create a Scene
www.devoxx.com
Scene {

width: 400

height: 400

background: Color.BLACK

}

48
Creating A Scene
www.devoxx.com
Top-level container for the scene

Contains only one Scene

Can set Stage width / height

Potentially represented by:

JFrame on desktop

JApplet on web page

SVG player on mobile
49
Stage
www.devoxx.com
DEMO
Create a Stage
www.devoxx.com
Stage {

style: StageStyle.TRANSPARENT

scene: Scene {

width: 400

height: 400

background: null

content: Rectangle { width: 100 height 100 }

}

}

51
Creating A Stage
www.devoxx.com
Node is the base class of the entire scene graph

Every Node has bounds

Every Node has transforms

translate

scale

rotate

affine

Every Node has a parent
52
Nodes
www.devoxx.com
id

styleClass

visible

opacity

focusable

focused

cache

clip
53
Node Variables
effect

translateX, translateY

scaleX, scaleY

rotate

transforms

hover

layoutBounds
www.devoxx.com
lookup(id)

onKeyPressed

onKeyReleased

onKeyTyped
54
Node Functions
onMouseClicked

onMouseDragged

onMouseEntered

onMouseExited

onMouseMoved

onMousePressed

onMouseReleased

onMouseWheelMoved
www.devoxx.com
Have zero or more children as “content”

Can specify a blend mode

The children are composited within the group according
to the blend mode
55
Groups
Top Source
Bottom Source
None OVERLAY
www.devoxx.com
Primary method of Scene Graph encapsulation

All other nodes are not extendable

Simply override the create() method
56
Custom Node
www.devoxx.com
// A Rectangle with a round top and square bottom

public class HalfRoundRectangle extends CustomNode {

protected override function create():Node {

Group {

content: [

Rectangle {

width:50, height:35, arcWidth:12, arcHeight:12

}

Rectangle { y:20, width:50, height:30 }

]

}

}

}
57
Half-round Rectangle
www.devoxx.com
Arc

Circle

Ellipse

Line

Path

Polygon

Rectangle
58
Shapes - Building Blocks
stroke

strokeWidth

fill

smooth
Basic Shapes Common Variables
www.devoxx.com
x, y, radius

Circles are centered about the point defined by (x, y)
59
Circle
www.devoxx.com
x, y, width, height

Use arcWidth, arcHeight to make a rounded rect

Rectangles are positioned with the top left corner at (x, y)

60
Rectangle
www.devoxx.com
Built up by various PathElements

LineTo

MoveTo

CurveTo

CubicCurveTo

etc
61
Path
www.devoxx.com
Colors

150+ built in colors (all the HTML & CSS built in values)

Color.web(“#aabbcc”)

Color.web(“blue”)

Color.rgb(128, 222, 21)
62
Colors
www.devoxx.com
startX, startY, endX, endY

Define the direction of the gradient

On the unit square

Stops define each step in the gradient. Each stop

Has an offset between 0...1

Has a Color
63
Linear Gradients
www.devoxx.com
DEMO
Create An App (Part 1)
www.devoxx.com
ImageView node shows images

Image represents an in memory Image

Image can load images in FG thread or BG thread

Both ImageView and Image can scale

Preserve ratio

Fit within a specific width/height

When fit on Image level, keeps smaller image in memory
65
Images
www.devoxx.com
DEMO
Create an App (Part 2)
www.devoxx.com
x, y, TextOrigin

By default, text positioned such that (x, y) is left baseline

Fonts can be specified on Text

Favor “fill” over “stroke”

Supports multiline text

Use alignment to align multiline text

To center text, compute the center via layout bounds
67
Text
www.devoxx.com
Used for text input

Use CSS to style the TextBox

“text” is changed to reflect the actual text in the TextBox

“value” is changed when the text is “committed” via
ENTER, TAB, etc

“action” function is invoked when ENTER pressed

“columns” specifies the preferred width based on the font
size and number of characters to display
68
Text Box
www.devoxx.com
Use wrapped Swing components

SwingButton

SwingComboBox

etc

Wrap any Swing component

SwingComponent.wrap(someSwingComponent)
69
Swing
www.devoxx.com
Effects are placed on Nodes

Many standard built in 

DropShadow

ColorAdjust

GaussianBlur

Glow

Reflection

more...
70
Effects
www.devoxx.com
DEMO
Create an App (Part 3)
www.devoxx.com
JavaFX supports both visual and audio media

Cross platform JavaFX Media file (fxm, mp3)

Also plays native formats (mov, wmv)

Media class represents a media file

MediaPlayer plays a Media file

MediaView is the Node which displays the Media

No built in Movie playing Control
72
Media
www.devoxx.com
Summary
JavaFX 1.0 SDK provides the APIs necessary for building
creative applications

Future updates to JavaFX will come regularly and quickly

1.1 release around Februrary 2009

1.5 release around June 2009

JavaFX 1.0 Production Suite allows you to use
professional graphics in your apps
73
www.devoxx.com
Concluding statement
Try JavaFX Today
www.devoxx.com
Q&A
www.devoxx.com
Thanks for your attention!
http://javafx.com

More Related Content

What's hot

Interfaces in JAVA !! why??
Interfaces in JAVA !!  why??Interfaces in JAVA !!  why??
Interfaces in JAVA !! why??
vedprakashrai
 
Java session13
Java session13Java session13
Java session13Niit Care
 
Java - Concurrent programming - Thread's basics
Java - Concurrent programming - Thread's basicsJava - Concurrent programming - Thread's basics
Java - Concurrent programming - Thread's basics
Riccardo Cardin
 
java-06inheritance
java-06inheritancejava-06inheritance
java-06inheritanceArjun Shanka
 
Advanced programming topics asma
Advanced programming topics asmaAdvanced programming topics asma
Advanced programming topics asma
AbdullahJana
 
Variables: names, bindings, type, scope
Variables: names, bindings, type, scopeVariables: names, bindings, type, scope
Variables: names, bindings, type, scope
suthi
 
Module Magic
Module MagicModule Magic
Module Magic
James Gray
 
Method Handles in Java
Method Handles in JavaMethod Handles in Java
Method Handles in Java
hendersk
 
Method Shelters : Another Way to Resolve Class Extension Conflicts
Method Shelters : Another Way to Resolve Class Extension Conflicts Method Shelters : Another Way to Resolve Class Extension Conflicts
Method Shelters : Another Way to Resolve Class Extension Conflicts
S Akai
 
Java Exception Handling, Assertions and Logging
Java Exception Handling, Assertions and LoggingJava Exception Handling, Assertions and Logging
Java Exception Handling, Assertions and Logging
Riccardo Cardin
 
Interface
InterfaceInterface
Interface
kamal kotecha
 
Java Basics
Java BasicsJava Basics
Java Basics
Brandon Black
 
Objective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central DispatchObjective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central Dispatch
Matteo Battaglio
 
Eugene Burmako
Eugene BurmakoEugene Burmako
Eugene Burmako
Volha Banadyseva
 
Oop02 6
Oop02 6Oop02 6
Oop02 6schwaa
 

What's hot (17)

Interfaces in JAVA !! why??
Interfaces in JAVA !!  why??Interfaces in JAVA !!  why??
Interfaces in JAVA !! why??
 
Java session13
Java session13Java session13
Java session13
 
Java - Concurrent programming - Thread's basics
Java - Concurrent programming - Thread's basicsJava - Concurrent programming - Thread's basics
Java - Concurrent programming - Thread's basics
 
java-06inheritance
java-06inheritancejava-06inheritance
java-06inheritance
 
Advanced programming topics asma
Advanced programming topics asmaAdvanced programming topics asma
Advanced programming topics asma
 
Variables: names, bindings, type, scope
Variables: names, bindings, type, scopeVariables: names, bindings, type, scope
Variables: names, bindings, type, scope
 
Module Magic
Module MagicModule Magic
Module Magic
 
Method Handles in Java
Method Handles in JavaMethod Handles in Java
Method Handles in Java
 
Method Shelters : Another Way to Resolve Class Extension Conflicts
Method Shelters : Another Way to Resolve Class Extension Conflicts Method Shelters : Another Way to Resolve Class Extension Conflicts
Method Shelters : Another Way to Resolve Class Extension Conflicts
 
Java Exception Handling, Assertions and Logging
Java Exception Handling, Assertions and LoggingJava Exception Handling, Assertions and Logging
Java Exception Handling, Assertions and Logging
 
Interface
InterfaceInterface
Interface
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Clean code
Clean codeClean code
Clean code
 
Objective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central DispatchObjective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central Dispatch
 
Eugene Burmako
Eugene BurmakoEugene Burmako
Eugene Burmako
 
Oop02 6
Oop02 6Oop02 6
Oop02 6
 
Lecture21
Lecture21Lecture21
Lecture21
 

Viewers also liked

Building Amazing Applications with JavaFX
Building Amazing Applications with JavaFXBuilding Amazing Applications with JavaFX
Building Amazing Applications with JavaFX
Richard Bair
 
Building Data Rich Interfaces with JavaFX
Building Data Rich Interfaces with JavaFXBuilding Data Rich Interfaces with JavaFX
Building Data Rich Interfaces with JavaFX
Stephen Chin
 
Java Rich Clients with JavaFX 2.0
Java Rich Clients with JavaFX 2.0Java Rich Clients with JavaFX 2.0
Java Rich Clients with JavaFX 2.0
Richard Bair
 
Practical Experience Building JavaFX Rich Clients
Practical Experience Building JavaFX Rich ClientsPractical Experience Building JavaFX Rich Clients
Practical Experience Building JavaFX Rich Clients
Richard Bair
 
Gaming JavaFX
Gaming JavaFXGaming JavaFX
Gaming JavaFX
Richard Bair
 
JavaFX Deployment
JavaFX DeploymentJavaFX Deployment
JavaFX Deployment
Richard Bair
 
Human Resource Management System Java Project
Human Resource Management System Java ProjectHuman Resource Management System Java Project
Human Resource Management System Java Project
Tutorial Learners
 
Internet mail system java project
Internet mail system java projectInternet mail system java project
Internet mail system java project
Tutorial Learners
 
JavaFX 101
JavaFX 101JavaFX 101
JavaFX 101
Richard Bair
 
Employee Management System UML Diagrams Use Case Diagram, Activity Diagram, S...
Employee Management System UML Diagrams Use Case Diagram, Activity Diagram, S...Employee Management System UML Diagrams Use Case Diagram, Activity Diagram, S...
Employee Management System UML Diagrams Use Case Diagram, Activity Diagram, S...
Mohammad Karim Shahbaz
 
Inventory management system
Inventory management systemInventory management system
Inventory management systemcopo7475
 
From Shabby to Chic
From Shabby to ChicFrom Shabby to Chic
From Shabby to Chic
Richard Bair
 
Enterprising JavaFX
Enterprising JavaFXEnterprising JavaFX
Enterprising JavaFX
Richard Bair
 

Viewers also liked (13)

Building Amazing Applications with JavaFX
Building Amazing Applications with JavaFXBuilding Amazing Applications with JavaFX
Building Amazing Applications with JavaFX
 
Building Data Rich Interfaces with JavaFX
Building Data Rich Interfaces with JavaFXBuilding Data Rich Interfaces with JavaFX
Building Data Rich Interfaces with JavaFX
 
Java Rich Clients with JavaFX 2.0
Java Rich Clients with JavaFX 2.0Java Rich Clients with JavaFX 2.0
Java Rich Clients with JavaFX 2.0
 
Practical Experience Building JavaFX Rich Clients
Practical Experience Building JavaFX Rich ClientsPractical Experience Building JavaFX Rich Clients
Practical Experience Building JavaFX Rich Clients
 
Gaming JavaFX
Gaming JavaFXGaming JavaFX
Gaming JavaFX
 
JavaFX Deployment
JavaFX DeploymentJavaFX Deployment
JavaFX Deployment
 
Human Resource Management System Java Project
Human Resource Management System Java ProjectHuman Resource Management System Java Project
Human Resource Management System Java Project
 
Internet mail system java project
Internet mail system java projectInternet mail system java project
Internet mail system java project
 
JavaFX 101
JavaFX 101JavaFX 101
JavaFX 101
 
Employee Management System UML Diagrams Use Case Diagram, Activity Diagram, S...
Employee Management System UML Diagrams Use Case Diagram, Activity Diagram, S...Employee Management System UML Diagrams Use Case Diagram, Activity Diagram, S...
Employee Management System UML Diagrams Use Case Diagram, Activity Diagram, S...
 
Inventory management system
Inventory management systemInventory management system
Inventory management system
 
From Shabby to Chic
From Shabby to ChicFrom Shabby to Chic
From Shabby to Chic
 
Enterprising JavaFX
Enterprising JavaFXEnterprising JavaFX
Enterprising JavaFX
 

Similar to JavaFX In Practice

JAVA(module1).pptx
JAVA(module1).pptxJAVA(module1).pptx
JAVA(module1).pptx
SRKCREATIONS
 
Structural pattern 3
Structural pattern 3Structural pattern 3
Structural pattern 3
Naga Muruga
 
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Soumen Santra
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
Hamid Ghorbani
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
Ajay Sharma
 
Dart for Java Developers
Dart for Java DevelopersDart for Java Developers
Dart for Java Developers
Yakov Fain
 
Presentation - Course about JavaFX
Presentation - Course about JavaFXPresentation - Course about JavaFX
Presentation - Course about JavaFX
Tom Mix Petreca
 
Java, what's next?
Java, what's next?Java, what's next?
Java, what's next?
Stephan Janssen
 
Lecture 5 interface.pdf
Lecture  5 interface.pdfLecture  5 interface.pdf
Lecture 5 interface.pdf
AdilAijaz3
 
Framework Design Guidelines For Brussels Users Group
Framework Design Guidelines For Brussels Users GroupFramework Design Guidelines For Brussels Users Group
Framework Design Guidelines For Brussels Users Group
brada
 
Java
JavaJava
Java lab-manual
Java lab-manualJava lab-manual
Java lab-manual
Khurshid Asghar
 
Knowledge of Javascript
Knowledge of JavascriptKnowledge of Javascript
Knowledge of Javascript
Samuel Abraham
 
Java OOP Concepts 1st Slide
Java OOP Concepts 1st SlideJava OOP Concepts 1st Slide
Java OOP Concepts 1st Slide
sunny khan
 
Java oops PPT
Java oops PPTJava oops PPT
Java oops PPT
kishu0005
 
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptxINDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
Indu65
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to Java
SMIJava
 
Synapseindia dot net development
Synapseindia dot net developmentSynapseindia dot net development
Synapseindia dot net development
Synapseindiappsdevelopment
 
PHP 5.5.0 ChangeLog
PHP 5.5.0 ChangeLogPHP 5.5.0 ChangeLog
PHP 5.5.0 ChangeLog
Dhiraj Pandey
 

Similar to JavaFX In Practice (20)

JAVA(module1).pptx
JAVA(module1).pptxJAVA(module1).pptx
JAVA(module1).pptx
 
Structural pattern 3
Structural pattern 3Structural pattern 3
Structural pattern 3
 
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Dart for Java Developers
Dart for Java DevelopersDart for Java Developers
Dart for Java Developers
 
Presentation - Course about JavaFX
Presentation - Course about JavaFXPresentation - Course about JavaFX
Presentation - Course about JavaFX
 
Java, what's next?
Java, what's next?Java, what's next?
Java, what's next?
 
Lecture 5 interface.pdf
Lecture  5 interface.pdfLecture  5 interface.pdf
Lecture 5 interface.pdf
 
Framework Design Guidelines For Brussels Users Group
Framework Design Guidelines For Brussels Users GroupFramework Design Guidelines For Brussels Users Group
Framework Design Guidelines For Brussels Users Group
 
Java
JavaJava
Java
 
Java scjp-part1
Java scjp-part1Java scjp-part1
Java scjp-part1
 
Java lab-manual
Java lab-manualJava lab-manual
Java lab-manual
 
Knowledge of Javascript
Knowledge of JavascriptKnowledge of Javascript
Knowledge of Javascript
 
Java OOP Concepts 1st Slide
Java OOP Concepts 1st SlideJava OOP Concepts 1st Slide
Java OOP Concepts 1st Slide
 
Java oops PPT
Java oops PPTJava oops PPT
Java oops PPT
 
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptxINDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to Java
 
Synapseindia dot net development
Synapseindia dot net developmentSynapseindia dot net development
Synapseindia dot net development
 
PHP 5.5.0 ChangeLog
PHP 5.5.0 ChangeLogPHP 5.5.0 ChangeLog
PHP 5.5.0 ChangeLog
 

Recently uploaded

Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 

Recently uploaded (20)

Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 

JavaFX In Practice

  • 2. www.devoxx.com JavaFX™ 1.0 In Practice Richard Bair Jasper Potts Martin Brehovsky Sun Microsystems
  • 3. www.devoxx.com Overall Presentation Goal Learn what JavaFX can do for you (and your customers)
  • 4. www.devoxx.com Our qualifications Richard, Jasper, and Martin are all on the JavaFX SDK team Martin lead the team responsible for the JavaFX Production Suite Richard is one of the API leads for JavaFX SDK Jasper is one of the key engineers on the JavaFX SDK 4
  • 5. www.devoxx.com JavaFX is the new client stack for graphical Java applications across all devices.
  • 6. www.devoxx.com Introduction to JavaFX JavaFX Script Scene Graph Music and Movies Animations and Transitions Tool Support Q & A 6 Agenda
  • 7. www.devoxx.com Common APIs across devices Scales from small devices to powerful desktops Brings rich media and graphical APIs to Java Simplifies building graphical consumer and enterprise applications 7 Introduction to JavaFX™
  • 8. www.devoxx.com Expression language Declarative and Procedural Integrates with Java Loosely based on JavaScript 8 JavaFX Script
  • 11. www.devoxx.com JavaFX Script source files are called “scripts” Scripts which expose no public API may be “loose” Everything* in JavaFX Script is an expression All blocks are expressions and the last line is the result The result of the println expression is null The JavaFX String primitive is java.lang.String 11 Hello World Explained
  • 13. www.devoxx.com var s = “Hello World”; var s2 = ‘I can use single quotes too’; var i = 10; var s3 = “The number is {i}”; var even = i mod 2 == 0; var s4 = “The number is {if (even) then ‘even’ else ‘odd’}”; var s5 = “The hex code for 1024 is {%x 1024}”; var s6 = “You can declare multiline strings” “Just like this. Notice no ‘+’ sign”; 13 Declaring Strings
  • 14. www.devoxx.com var d = 23s; var d2 = 2.3ms; var d3 = 25.5 * 1.13s; var d4 = 5m; var d5 = 10h; 14 Declaring Durations
  • 15. www.devoxx.com JavaFX has “Sequences”, not arrays A Sequence is an immutable ordered list of non-null elements JavaFX supports sequence comprehensions Sequences can be “sliced” Sequences can optimize memory usage 15 Declaring Sequences
  • 16. www.devoxx.com // A sequence of all the positive non zero integers. This // actually uses very little memory since the range is // remembered, not the values (since sequences are // immutable) var ints = [1..java.lang.Integer.MAX_INT]; println(sizeof ints); // creates a subsequence which contains all positive non // zero even integers var even = ints[n | n mod 2 == 0]; // a simple sequence of strings var names = [“Jasper”, “Richard”, “Martin”]; 16 Declaring Sequences
  • 17. www.devoxx.com // A sequence of one can omit the brackets var names:String[] = “Richard”; // Empty sequences are not null var names:String[]; println(sizeof names); // prints 0 // elements are accessed by index var names = [“Jasper”, “Richard”, “Martin”]; var martin = names[2]; // and you can populate a sequence using a for loop var hellos = for (i in [1..3]) { “Hello #{i}” } 17 Declaring More Sequences
  • 18. www.devoxx.com // Inserting items into a sequence var names:String[] = “Richard”; insert “Jasper” into names; // Inserting before a certain index insert “Martin” before names[1]; // Inserting after a certain index insert “Duke” after names[1]; // Deleting from the sequence delete “Duke” from names; 18 Modifying Sequences
  • 19. www.devoxx.com + - / * ++ -- *= /= += -= and or not = == != mod 19 Operators
  • 20. www.devoxx.com if ( booleanExpression) then a else b if (booleanExpression) a else b if (booleanExpression) { a } else { b } while (booleanExpression) { ... } for (i in sequence) { ... } Can get index of item “i” by “indexof i” break continue 20 Flow Control
  • 21. www.devoxx.com if ( booleanExpression) then a else b An if expression returns either “a” or “b” as the result If “a” or “b” is a block, then it returns the last line of the block that was selected by the if statement While and For are expressions which return a sequence filled with the result of the last line of the block 21 Flow Control Expressions
  • 22. www.devoxx.com name:type style syntax Type inference var for variables, def for definitions 22 Declaring Variables
  • 23. www.devoxx.com // I cannot be changed. I’m inferred to be a Number. def pi = 3.141592; // I can be changed. And I’ve been explicitly declared // as a Number var radius:Number = 7; // same as above except by type inference it thinks it is an // Integer var radius2 = 7; 23 Declaring Variables
  • 24. www.devoxx.com name(args):type style syntax Type inference Must use keyword function Must use keyword override when overriding a function May be public, package, protected, or implicitly private May be anonymous (ie: closure) 24 Declaring Functions
  • 25. www.devoxx.com // A private function which returns the min of the two args function min(first:Number, second:Number):Number { if (first <= second) then first else second } // a function variable and anonymous function declaration // and function invocation var onError:function(e:Exception):Void; onError = function(e:Exception):Void { e.printStackTrace(); } onError(e); 25 Declaring Functions
  • 26. www.devoxx.com Classes extend classes or interfaces Scope modifiers: public, protected, package Implicitly “script private” init { } and postinit { } blocks take place of Constructors Functions and variables declared outside a class are static Multiple classes may be defined in a single Script 26 Declaring Classes
  • 27. www.devoxx.com // This class extends a Java interface public class FooModel extends TableModel { ... } // This class defines two variables and a function public class Location { public var x:Number; public var y:Number; public function move(newX:Number, newY:Number):Void { x = newX; y = newY; } } 27 Declaring Classes
  • 28. www.devoxx.com Variables use scope modifiers for read & write access public protected package “script private” by default Variables can have additional modifiers to modify write access public-read public-init 28 Variable Scope Modifiers
  • 29. www.devoxx.com public class ImmutableFoo { // This variable can be initialized by anyone, but // modified only by this script public-init var name:String; } public class ReadOnly extends { public var x1:Number; public var x2:Number; // This variable can only be read by everyone, it cannot // be initialized or mutated outside this script public-read var distance:Number; } 29 Variable Scope Modifiers
  • 30. www.devoxx.com Variables are initialized from base class to child class in the order in which they are declared Variables are only initialized once init { } blocks are called after all variables in the class have been initialized Parent class init { } blocks are called before child init { } postinit { } blocks are called after the init { } block Parent class postinit { } blocks are called after child postinit { } blocks 30 Class Initialization
  • 31. www.devoxx.com public class Parent { public var name = “Richard”; init { println(“name is {name}”); } } public class Child extends Parent { override var name = “Luke”; } 31 Variable Initialization Order
  • 32. www.devoxx.com // prints out “Richard” var parent = Parent { }; // prints out “Luke” var child = Child { }; 32 Variable Initialization Order
  • 33. www.devoxx.com Variables can have on replace triggers to execute procedural code when the bound variable is updated Triggers execute in an undefined order Variables can have multiple triggers Triggers are fired for every set, including initialization 33 Triggers
  • 34. www.devoxx.com public class Location { public var x:Number on replace { println(“New X Value is {x}”); } public var y:Number on replace { println(“New Y Value is {y}”); } } 34 Triggers
  • 35. www.devoxx.com bind is a way to tie the value of one variable to the value of an expression binding must be defined when the variable is initialized bindings are statically compiled bound variables cannot be set manually use bind with inverse for bidirectional binding 35 Bind
  • 36. www.devoxx.com public class Distance extends { public var x1:Number; public var x2:Number; // Whenever x2 or x1 changes, distance will be updated // Binding can be used for invariants public-read var distance:Number = bind x2 - x1; } 36 Simple Binding Example
  • 37. www.devoxx.com Concise declarative syntax for object creation Similar to JavaScript Combine with binding for maximum effect variable: initial-value initial-value is an expression 37 Object Literals
  • 38. www.devoxx.com // creates a Rectangle // x: 10 is not an assignment, it is an initialization! var rect = Rectangle { x: 10 y: 10 width: 100 height: 100 } 38 Object Literal
  • 39. www.devoxx.com // creates a Rectangle with a Color for its fill var rect = Rectangle { x: 10 y: 10 width: 100 height: 100 fill: Color { red: 1 green: 0 blue: 0 } } 39 Nesting Object Literals
  • 40. www.devoxx.com // Notice that I can declare a var and use it in the literal var rect = Rectangle { var color = Color { red: 1 green: 0 blue: 0 } x: 10 y: 10 width: 100 height: 100 fill: color } 40 Vars in Object Literals
  • 41. www.devoxx.com // A variation that allows me to reference the color later var color:Color; var rect = Rectangle { x: 10 y: 10 width: 100 height: 100 fill: color = Color { red: 1 green: 0 blue: 0 } } 41 Vars in Object Literals
  • 42. www.devoxx.com // Here I’ll choose the color to use based on some boolean var highContrast = false; var rect = Rectangle { x: 10 y: 10 width: 100 height: 100 fill: bind if (highContrast) then BLACK else GRAY } highContrast = true; 42 Object Literal With If
  • 43. www.devoxx.com Describes the graphics and controls in a scene Each node in the graph has a single parent Special “group” nodes have zero or more children “leaf” nodes have no children Graph is set on a Scene Scene is set in a Stage 43 Scene Graph
  • 46. www.devoxx.com Canvas upon which the Scene Graph is displayed Can set multiple CSS Stylesheets Can set background color (or set to null) Can set canvas width / height 46 Scene
  • 48. www.devoxx.com Scene { width: 400 height: 400 background: Color.BLACK } 48 Creating A Scene
  • 49. www.devoxx.com Top-level container for the scene Contains only one Scene Can set Stage width / height Potentially represented by: JFrame on desktop JApplet on web page SVG player on mobile 49 Stage
  • 51. www.devoxx.com Stage { style: StageStyle.TRANSPARENT scene: Scene { width: 400 height: 400 background: null content: Rectangle { width: 100 height 100 } } } 51 Creating A Stage
  • 52. www.devoxx.com Node is the base class of the entire scene graph Every Node has bounds Every Node has transforms translate scale rotate affine Every Node has a parent 52 Nodes
  • 55. www.devoxx.com Have zero or more children as “content” Can specify a blend mode The children are composited within the group according to the blend mode 55 Groups Top Source Bottom Source None OVERLAY
  • 56. www.devoxx.com Primary method of Scene Graph encapsulation All other nodes are not extendable Simply override the create() method 56 Custom Node
  • 57. www.devoxx.com // A Rectangle with a round top and square bottom public class HalfRoundRectangle extends CustomNode { protected override function create():Node { Group { content: [ Rectangle { width:50, height:35, arcWidth:12, arcHeight:12 } Rectangle { y:20, width:50, height:30 } ] } } } 57 Half-round Rectangle
  • 58. www.devoxx.com Arc Circle Ellipse Line Path Polygon Rectangle 58 Shapes - Building Blocks stroke strokeWidth fill smooth Basic Shapes Common Variables
  • 59. www.devoxx.com x, y, radius Circles are centered about the point defined by (x, y) 59 Circle
  • 60. www.devoxx.com x, y, width, height Use arcWidth, arcHeight to make a rounded rect Rectangles are positioned with the top left corner at (x, y) 60 Rectangle
  • 61. www.devoxx.com Built up by various PathElements LineTo MoveTo CurveTo CubicCurveTo etc 61 Path
  • 62. www.devoxx.com Colors 150+ built in colors (all the HTML & CSS built in values) Color.web(“#aabbcc”) Color.web(“blue”) Color.rgb(128, 222, 21) 62 Colors
  • 63. www.devoxx.com startX, startY, endX, endY Define the direction of the gradient On the unit square Stops define each step in the gradient. Each stop Has an offset between 0...1 Has a Color 63 Linear Gradients
  • 65. www.devoxx.com ImageView node shows images Image represents an in memory Image Image can load images in FG thread or BG thread Both ImageView and Image can scale Preserve ratio Fit within a specific width/height When fit on Image level, keeps smaller image in memory 65 Images
  • 67. www.devoxx.com x, y, TextOrigin By default, text positioned such that (x, y) is left baseline Fonts can be specified on Text Favor “fill” over “stroke” Supports multiline text Use alignment to align multiline text To center text, compute the center via layout bounds 67 Text
  • 68. www.devoxx.com Used for text input Use CSS to style the TextBox “text” is changed to reflect the actual text in the TextBox “value” is changed when the text is “committed” via ENTER, TAB, etc “action” function is invoked when ENTER pressed “columns” specifies the preferred width based on the font size and number of characters to display 68 Text Box
  • 69. www.devoxx.com Use wrapped Swing components SwingButton SwingComboBox etc Wrap any Swing component SwingComponent.wrap(someSwingComponent) 69 Swing
  • 70. www.devoxx.com Effects are placed on Nodes Many standard built in DropShadow ColorAdjust GaussianBlur Glow Reflection more... 70 Effects
  • 72. www.devoxx.com JavaFX supports both visual and audio media Cross platform JavaFX Media file (fxm, mp3) Also plays native formats (mov, wmv) Media class represents a media file MediaPlayer plays a Media file MediaView is the Node which displays the Media No built in Movie playing Control 72 Media
  • 73. www.devoxx.com Summary JavaFX 1.0 SDK provides the APIs necessary for building creative applications Future updates to JavaFX will come regularly and quickly 1.1 release around Februrary 2009 1.5 release around June 2009 JavaFX 1.0 Production Suite allows you to use professional graphics in your apps 73
  • 76. www.devoxx.com Thanks for your attention! http://javafx.com