JJUG-Whats-New-For-JavaFX-in-JDK8
-
Upload
oracle-fusion-middleware -
Category
Technology
-
view
106 -
download
0
description
Transcript of JJUG-Whats-New-For-JavaFX-in-JDK8
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 131
New JavaFX Features in JDK 8(after a gentle intro to app development with JavaFX)
Jim Weaver
Java Technology Ambassador
Oracle Corporation
@JavaFXpert
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 132 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16
ProgramAgenda
Intro to app development with JavaFX
– Obtaining JavaFX resources
– Creating a user interface
– Using Scene Builder and FXML
New JavaFX Features in JDK 8
– Some new Java features in JDK 8
– New JavaFX Features in JDK 8
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 133 3
Please note
The following is intended to outline our general product
direction. It is intended for information purposes only, and
may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality,
and should not be relied upon in making purchasing
decisions. The development, release, and timing of any
features or functionality described for Oracle’s products
remains at the sole discretion of Oracle.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 134
■ An API included in Java SE 7/8
for UI development
■ The successor to Java Swing
■ Not the JavaFX Script language
4
JavaFX is:
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 135
To Get JavaFX, Download Java 7
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 136
To Develop JavaFX, Use Your Fav IDE
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 137 7
Start Here: http://javafxcommunity.com
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 138 8
Download JDK 8 Early Access Release
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 139
Download Samples (e.g. Ensemble 8)http://jdk8.java.net/download.html
9
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1310
Ensemble in Mac App Store
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1311 11
Get Pro JavaFX 2 Book Resources
First chapter and all code samples available
at http://ProJavaFX2.com for free
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1312 12
Visit Here: http://fxexperience.com
Tip: This site is authored by Oracle JavaFXEngineers, and often contains news about 3D
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1313
Creating a User Interface
The MetronomeTransition
example is in the Pro JavaFX 2
code download
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1314
Extend javafx.application.Application
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1315
Override the Application start() Method
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1316
Create a Scene
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1317
Populate the Scene Graph
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1318
Handle Events
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1319
Call the Animation Methods
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1320
Animate the Circle
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1321
Bind UI Properties to Animation Status
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1322
Setup and Show the Stage
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1323
Some New Java Features in JDK 8
■ Nashorn JavaScript Engine
■ Date & Time API
■ Bulk data operations for collections
■ Lambda expressions and virtual extension methods
23
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1324
A Lambda Expression (Closure) is…
…a function that that may have parameters,
an expression or block of code, optionally
returning a value.
24
e -> anim.playFromStart()
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1325 25
Event Handling w/Anon Inner Classes
Any interface that has exactly one abstract method is known as a
functional interface, and may be replaced by a lambda expression.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1326 26
Replace with Lambda Expression
The type of the lambda is inferred by the compiler as EventHandler<ActionEvent> because the onAction() method
takes an object of type EventHandler<ActionEvent>.
Because EventHandler has a single method handle() the lambda
expression must be an implementation of the handle() method.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1327 27
Simplify the Lambda Expression
The parameter in this lambda expression must be an ActionEvent, because that is the type specified by the
handle() method of the EventHandler interface.
We can therefore simplify this lambda expression
because the parameter type is inferred.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1328 28
Lose the Parentheses
When a lambda expression has a single parameter and
its type is inferred, the parentheses are not required
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1329 29
Lose the Braces
Because the block of code in our lambda expression
contains only one statement, we can lose the braces.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1330 30
MetronomeTransition w/Lambdas
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1331
Blog Post with More Detail
http://JavaFXpert.com/2013/02/mary-had-a-little-%CE%BB.html
31
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1332
New JavaFX Features in JDK 8
■ New Modern Theme: Modena
■ JavaFX 3D
■ Rich Text
■ TreeTableView
■ DatePicker
■ Public API for CSS structure
■ WebView Enhancements
■ Embedded Support
32
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1333
New Modern Theme: Modena
33
http://fxexperience.com/2013/03/modena-theme-update/
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1334
“JavaFX 3D gives you the ability to use 3D geometry, cameras, and lights in JavaFX.”
JavaFX 3D
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1335
JavaFX 3D Application Example
35
http://fxexperience.com/2013/02/javafx-3d-early-access-available/
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1336
Mesh Geometry (3D Shapes)
■ Predefined shapes
■ Box
■ Cylinder
■ Sphere
■ User-defined shapes
■ Using TriangleMesh / MeshView
36
https://wikis.oracle.com/display/OpenJDK/SphereAndBox.java
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1337 37
Creating Primitive Shapes and Materials
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1338
3D Materials and Textures
■ PhongMaterial has these properties
■ Ambient color
■ Diffuse color, diffuse map
■ Specular color, specular map
■ Specular power
■ Normal map
■ Self-illumination map
38
https://wikis.oracle.com/display/OpenJDK/3D+Features
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1339
3D Lights
■ Lights are nodes in the scene graph
■ PointLight
■ AmbientLight
■ Default light provided if no active lights
39
https://wikis.oracle.com/display/OpenJDK/3D+Features
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1340 40
Lights, Camera, Action!
Tip: The camera is a node in the scene graph, so it is moveable
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1341
Rich Text
■ Use Cases
■ text editor ● code editor ● mixed style Labels, buttons, cells ●
headings ● descriptions ● large textual content ● etc.
■ Details
■ TextFlow, a new layout container
■ Text is just a node… so you can add effects, event handlers, and
animations
■ You can also use CSS, FXML
41
https://wikis.oracle.com/display/OpenJDK/Rich+Text
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1342
Rich Text Examples
42
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1343
TreeTableView
■ Goal: reuse as many API, or API concepts, as possible from the
TreeView and TableView controls API
43
https://wikis.oracle.com/display/OpenJDK/TreeTableView
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1344
DatePicker
44
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1345
Public API for CSS structure
■ CSS styling is one of the key features for JavaFX
■ CSS has been implemented exclusively in private API
(com.sun.javafx.css package)
■ Tools (e.g. Scene Builder) require a CSS public API
■ Developers will be able to define custom CSS styles
45
https://wikis.oracle.com/display/OpenJDK/CSS+API+to+support+custom+UI+Controls
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1346
WebView Enhancements
■ Nashorn JavaScript engine
■ https://blogs.oracle.com/nashorn/entry/open_for_business
■ WebSocket
■ http://javafx-jira.kenai.com/browse/RT-14947
■ Web Workers
■ http://javafx-jira.kenai.com/browse/RT-9782
46
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1347
Embedded Support
■ JavaFX to be included in Oracle’s implementation of
■ Java SE 8 (x86, x64, ARM)
■ Java SE Embedded 8 (ARM)
■ Java SE Embedded 8 will include a subset of the JavaFX
features to be released in the desktop version
■ No WebView support
■ No media support
47
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1348
RoadmapJavaFX
20152013 2014
JDK 8 (Q1 2014)• Lambda
•JVM Convergence
• JavaScript Interop
• JavaFX 8
– 3D API
– Java SE Embedded support
– Enhanced HTML5 support
7uX• Java Flight Recorder in JDK
• Native memory tracking
• Java Discovery Protocol
• App Store Packaging tools
JDK 9• Jigsaw
• Interoperability
• Optimizations
• Cloud
• Ease of Use
• JavaFX JSR
NetBeans IDE 7.3• New hints and refactoring
• Scene Builder Support
NetBeans IDE 8• JDK 8 support
• Scene Builder 2.0 support
Scene Builder 2.0• JavaFX 8 support
• Enhanced Java IDE support
NetBeans IDE 9• JDK 9 support
• Scene Builder 3.0 support
SceneBuilder 3.0• JavaFX 9 support
Apr CPU• Java Client
Security
Enhancements
2016
JDK 8.1 (Q3 2014)• Deterministic G1
• JMC 6
• Improved JRE installer
• App bundling
enhancements
JDK 8.2
Scene Builder 1.1• Linux support
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1349
Call to Action
■ Download and play with JDK 8 / JavaFX 8 features
■ Share your experiences with JavaFX community by blogging
and tweeting #JavaFX
■ Send me [email protected] an RSS feed to the JavaFX
category of your blog so I can include your posts on
http://javafxcommunity.com
49
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1350
Questions?
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1351
New JavaFX Features in JDK 8(after a gentle intro to app development with JavaFX)
Jim Weaver
Java Technology Ambassador
Oracle Corporation
@JavaFXpert
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1352