![Page 1: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/1.jpg)
1
Exploring JavaFX 8
Stephen Chin (@steveonjava)
Java Technology Ambassador
JavaOne Content Chair
♯jdt2014_A3
![Page 2: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/2.jpg)
2
• Cross-platform Animation, Video, Charting
• Integrate Java, JavaScript, and HTML5 in the
same application
• New graphics stack takes advantage of hardware
acceleration for 2D and 3D applications
• Bidirectional integration with Swing applications
using JFXPanel and SwingNode
Immersive Application Experience
JavaFX Platform
![Page 3: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/3.jpg)
3
How to Get JavaFX
Step 1: Download Java 8
![Page 4: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/4.jpg)
4
How to Develop JavaFX Use Your Favorite IDE
![Page 5: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/5.jpg)
5
Architecture of JavaFX 8
Java Virtual Machine
Java2D Open GL D3D
Prism Glass
WinTk
Media
Engine
Web
Engine
JavaFX Public API
Quantum Toolkit
![Page 6: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/6.jpg)
6
Package Your Application Applets, Web Start, and Native Packaging
Good Better Best
![Page 7: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/7.jpg)
7
New Features in JavaFX 8
![Page 8: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/8.jpg)
Controls
![Page 9: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/9.jpg)
9
DatePicker
Allows selection of dates
and ranges
Can use custom formats
and calendars
Supports Cascading Style
Sheets
![Page 10: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/10.jpg)
10
TreeTableView
Combines a TreeView and a
TableView
Optional menu for hiding and
showing columns
Root can be hidden
Supports multiple selection
Supports CSS
![Page 11: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/11.jpg)
11
New Modena UI Theme
![Page 12: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/12.jpg)
12
![Page 13: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/13.jpg)
13
Build Applications Visually JavaFX Scene Builder 2
![Page 14: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/14.jpg)
14
![Page 15: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/15.jpg)
15
Displaying HTML in JavaFX
public class WebViewTest extends Application {
public static void main(String[] args) {
launch(WebViewTest.class, args);
}
@Override public void start(Stage stage) {
WebView webView = new WebView();
webView.getEngine().load("http://google.com");
Scene scene = new Scene(webView);
stage.setScene(scene);
stage.setTitle("Web Test");
stage.show();
}}
![Page 16: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/16.jpg)
16
Displaying HTML in JavaFX
![Page 17: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/17.jpg)
17
Calling Javascript from JavaFX
String script = "alert('We have got a message, Houston!');”;
eng.executeScript(script);
![Page 18: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/18.jpg)
18
JavaScript to Java Type Conversion
JavaScript Java
null null
undefined “undefined”
number java.lang.Number (Integer or
Double)
string java.lang.String
boolean java.lang.Boolean
object netscape.javascript.JSObject
![Page 19: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/19.jpg)
19
Responding to Browser Events
Alert/Confirm/Prompt – Respond to JavaScript user interaction
functions
• Resize – Web page moves or resizes the window object
• Status – Web page changes the status text
• Visibility – Hide or show the window object
• Popup – Spawn a second web view/engine
![Page 20: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/20.jpg)
20
HTML5 Features
Canvas and SVG
Media playback
Form controls
History maintenance
Interactive element tags
DOM
Web workers*
Web sockets*
Web fonts*
* = new in HTML5
![Page 21: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/21.jpg)
21
The Java Conference Tour app
![Page 22: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/22.jpg)
22
JAVAFX 3D
![Page 23: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/23.jpg)
23
Mesh Geometry (3D Shapes)
■ Predefined shapes
■ Box
■ Cylinder
■ Sphere
■ User-defined shapes
■ Using TriangleMesh / MeshView
23
https://wikis.oracle.com/display/OpenJDK/SphereAndBox.java
![Page 24: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/24.jpg)
24 24
Creating Primitive Shapes and Materials
![Page 25: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/25.jpg)
25 25
Rotating the 3D Shapes
Tip: Use lambda expressions as
shown here to simplify event handling
![Page 26: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/26.jpg)
26
3D Materials and Textures
■ PhongMaterial has these properties
■ Ambient color
■ Diffuse color, diffuse map
■ Specular color, specular map
■ Specular power
■ Bump map
■ Self-illumination map
26
https://wikis.oracle.com/display/OpenJDK/3D+Features
![Page 27: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/27.jpg)
27
UV Mapping Textures to Shapes
27
Tip: A texture is a 2D image to
be mapped on a 3D surface
Source: http://en.wikipedia.org/wiki/File:UVMapping.png
![Page 28: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/28.jpg)
28
Placing a Texture on a Sphere
28
![Page 29: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/29.jpg)
29
Placing a Texture on a Sphere
29
![Page 30: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/30.jpg)
30
UV Mapping on a Cube
30
![Page 31: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/31.jpg)
31
Understanding TriangleMesh
31
8 points
12 faces
14 texCoords
12 faces
Image
0, 0
0, 1
1, 0
1, 1
Tip: Best practice
for texture map
dimensions is
powers of two
(e.g. 1024x512)
![Page 32: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/32.jpg)
32
Using TriangleMesh Points
32
Tip: The API for points,
texCoords, and faces is
currently being modified,
primarily to hold this data
in different structures.
(For example)
![Page 33: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/33.jpg)
33
Using TriangleMesh Texture Coords
33
(For example)
![Page 34: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/34.jpg)
34
Using TriangleMesh Faces
34
0, 2, 1 are points[] indices
10, 5, 9 are texCoords[] indices
![Page 35: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/35.jpg)
35
Using TriangleMesh Smoothing Groups
35
These are faces[] indices
(and putting all the pieces together of our user-defined shape)
![Page 36: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/36.jpg)
36 36
Real-World Example of Mesh Geometry
![Page 37: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/37.jpg)
37
3D Lights
■ Lights are nodes in the scene graph
■ PointLight
■ AmbientLight
■ Default light provided if no active lights
37
https://wikis.oracle.com/display/OpenJDK/3D+Features
![Page 38: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/38.jpg)
38 38
Lights, Camera, Action!
Tip: The camera is also a node in
the scene graph, so it is moveable
![Page 39: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/39.jpg)
39
=
Have Java With Your Dessert Raspberry Pi
![Page 40: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/40.jpg)
40 http://elinux.org/File:Raspi-Model-AB-Mono-2-699x1024.png
![Page 41: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/41.jpg)
41
Embedded Controls Theme
![Page 42: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/42.jpg)
42
Virtual Keyboard
![Page 43: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/43.jpg)
43
JavaFX on Raspberry Pi Gotchas
WebView Media
![Page 44: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/44.jpg)
44
And you can do cool stuff like this… https://bitbucket.org/stephanj/tweetwall
![Page 45: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/45.jpg)
45
Stephen Chin tweet: @steveonjava
blog: http://steveonjava.com
nighthacking.com
Real Geeks Live Hacking
NightHacking Tour
![Page 46: Exploring JavaFX 8 - Oracleotndnld.oracle.co.jp/ondemand/javaday2014/pdf/A3-JavaDay...46 The preceding is intended to outline our general product direction. It is intended for information](https://reader030.vdocuments.mx/reader030/viewer/2022011812/5e2c11a48947e617cc0bf77e/html5/thumbnails/46.jpg)
46
The preceding 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.