New JavaFX Features in Java 8
(and an intro to Lambdas)
James Weaver
Java Technology Ambassador
Oracle Corporation
@JavaFX...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.2 Copyright © 2012, Oracle and/or its affiliates. All ...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.3
About the presenter
Author of several Java/JavaFX bo...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.4
About the presenter
Co-leader of IoT & JavaFX commun...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.5
About the presenter
Favorite TV shows are music comp...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.6
About the presenter
I see that Italy has “The Voice”...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.7
About the presenter
… with a singing Nun. Very cool!
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.8
Java 8 Launch Event & Resource Videos
oracle.com/jav...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.9
IoT Developer Challenge
 Show the world what you ca...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.10
■ An API included in Java SE 7/8
for UI development...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.11
Creating a User Interface
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.12
New JavaFX Application Dialog
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.13
Extend javafx.application.Application
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.14
Override the Application start() Method
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.15
Create the Circle
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.16
Create the Buttons and Handle Events
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.17
Layout the Buttons in an HBox
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.18
Create and Populate the Scene
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.19
Animate the Circle
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.20
Bind UI Properties to Animation Status
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.21
Setup and Show the Stage
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.22
Using Scene Builder and FXML
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.23
Scene Builder is a...
■ UI layout tool for
JavaFX
■...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.24
FXML is...
■ an XML-based language that
expresses t...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.25
Download Scene Builder
http://www.oracle.com/techne...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.26
Scene Builder 2.0 Preview Available
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.27
Some New Java Features in JDK 8
■ Nashorn JavaScrip...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.28
Compact Profiles
Approximate static footprint goals...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.29
Java SE Embedded
 Optimised binary for embedded us...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.30
A Lambda Expression (Closure) is…
…a function that ...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.31 31
Event Handling w/Anon Inner Classes
Any interfac...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.32 32
Replace with Lambda Expression
The type of the l...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.33 33
Simplify the Lambda Expression
The parameter in ...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.34 34
Lose the Parentheses
When a lambda expression ha...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.35 35
Lose the Braces
Because the block of code in our...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.36
void createUI() {
Button button = new Button("Guess...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.37
… you can use a method reference
void createUI() {
...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.38
Four Kinds of Method References
1) Reference to a s...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.39
Another Method Reference Example
FileFilter x = f -...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.40
JavaFXpert.com blog post with more detail
40
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.41
Project Nashorn
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.42
Nashorn
var Rectangle = Java.type("javafx.scene.sha...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.43
Nashorn
var rect = new Rectangle();
rect.width = 20...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.44
Nashorn: Launching JavaFX
$JDK_HOME/bin/jjs -fx hel...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.45
Nashorn FX
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.46
New JavaFX Features in JDK 8
■ New Modern Theme: Mo...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.47
JavaFX 8
New Theme Caspian
vs
Modena
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.48
Modena
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.49
Modena
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.50
JavaFX 8
 Customisable
– Configurable key combinat...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.51
JavaFX 8
 New API for printing
– Currently only su...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.52
JavaFX 8
 DatePicker
 TreeTableView
New Controls
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.53
java.time
DatePicker
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.54 54
DatePicker
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.55
DatePicker
import java.time.LocalDate; // From new ...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.56
Date Picker
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.57
TreeTableView
UI control with combined TreeView and...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.58
JavaFX 8
 Gestures
– Swipe
– Scroll
– Rotate
– Zoo...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.59
Touch Gestures
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.60
The Swipe Gesture
 Commonly a finger drag in one d...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.61
Handling the Swipe Gesture (SwipeEvent)
Note: Lambd...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.62
Handling the Swipe Gesture (SwipeEvent)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.63
The Scroll Gesture
 User turns mouse wheel, drags ...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.64
Handling the Scroll Gesture (ScrollEvent)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.65
The Rotate Gesture
 User typically drags two finge...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.66
Handling the Rotate Gesture (RotateEvent)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.67
The Zoom Gesture
 User typically drags two fingers...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.68
Handling the Zoom Gesture (ZoomEvent)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.69
Handling Touch (TouchEvent/TouchPoint)
 A TouchEve...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.70
Responding to Touch Events
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.71
JavaFX 8
 Predefined shapes
– Box
– Cylinder
– Sph...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.72 72
Creating Primitive Shapes and Materials
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.73
Placing a Texture on a Sphere
73
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.74
Placing a Texture on a Sphere
74
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.75
3D Lights
■ Lights are nodes in the scene graph
■ P...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.76 76
Lights, Camera, Action!
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.77
Example 3D multi-touch app:
ZenGuitar3D
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.78
Questions?
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.79 79
Please note
The preceding is intended to outline...
New JavaFX Features in Java 8
(and an intro to Lambdas)
James Weaver
Java Technology Ambassador
Oracle Corporation
@JavaFX...
Upcoming SlideShare
Loading in...5
×

What's new for JavaFX in JDK8 - Weaver

1,738

Published on

Le slide di James Weaver presentate a Codemotion Roma 2014

Published in: Technology, News & Politics
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,738
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
43
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide
  • Welcome to the latest and greatest version of the Java platform, Java 8
  • The Java 8 Launch site is a great place to find resource videos on Java 8.
  • The Java 8 Launch site is a great place to find resource videos on Java 8.
  • Modularisation of the Java platform. Since project Jigsaw was pushed back to Java SE 9 some form of modularisation was needed to make the Java platform more flexible. To do this we now have three compact profiles that subset the standard class libraries to allow applications that only need certain APIs to run in a smaller resource footprint.Compact 1 is the smallest subset of packages that supports the Java language. Includes logging and SSL. This is the migration path for people currently using the compact device configuration (CDC)Compact 2 adds support for XML, JDBC and RMI (specifically JSR 280, JSR 169 and JSR 66)Compact 3 adds management, naming, more securoty and compiler support.None of the compact profiles include any UI APIs, they are all headless.See also JEP 161
  • Java SE Embedded is a binary distribution of Java SE that runs on the ARM processor architecture version 6 and 7 and supports hardware floating point accelerationOne of the reference platforms is the Raspberry Pi providing a very low cost way to develop and test Java SE Embedded applications.
  • JavaFX 8 includes a new stylesheet, named Modena. This provides a more modern look to JavaFX 8. The older, Caspian, stylesheet can still be used.
  • Java FX 8 includes improvements to support for full screen mode. For applications like kiosks and terminals it is now possible to configure special key sequences to exit full screen mode, or even to disable the ability to exit full screen mode altogether,
  • JavaFX 8 includes a printing API, so any node from the scenegraph can be printed. This feature is currently only supported on the desktop version of JavaFX, it is not currently supported in the embedded version.
  • JavaFX 8 includes a few new controls. Most notable of these is the date picker, which has been something people have been asking for. A combination table and tree view has also been included.
  • As more devices are supporting the concept of touch interfaces JavaFX supports these types of interface using specific APIs. Gestures like swipe, scroll, zoom and rotate are supported as event listeners and touch specific events can be detected as well as multiple touch points.
  • JavaFX 8 adds comprehensive support for 3D interfaces. All the features you would expect ot find are available. Basic shapes that can be combined to form more complex shapes as well as the ability to construct shapes of arbritary complexity using meshes and trangle meshes.PhongMaterials are used to define how the surface of a 3D shape is rendered and these can include texture mappings.Both lighting sources and camera types and positions can be specified,
  • Welcome to the latest and greatest version of the Java platform, Java 8
  • What's new for JavaFX in JDK8 - Weaver

    1. 1. New JavaFX Features in Java 8 (and an intro to Lambdas) James Weaver Java Technology Ambassador Oracle Corporation @JavaFXpert james.weaver@oracle.com
    2. 2. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Program Agenda  Introduction to JavaFX – Creating a user interface – Understanding Scene Builder and FXML  New JavaFX Features in JDK 8 – Some new Java features in JDK 8 – New JavaFX Features in JDK 8
    3. 3. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.3 About the presenter Author of several Java/JavaFX books
    4. 4. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.4 About the presenter Co-leader of IoT & JavaFX communities at java.net javafxcommunity.com iotcommunity.net
    5. 5. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.5 About the presenter Favorite TV shows are music competitions like “The Voice”
    6. 6. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.6 About the presenter I see that Italy has “The Voice” as well …
    7. 7. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.7 About the presenter … with a singing Nun. Very cool!
    8. 8. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.8 Java 8 Launch Event & Resource Videos oracle.com/java8
    9. 9. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.9 IoT Developer Challenge  Show the world what you can do with Java + IoT for a chance to win a trip to JavaOne for you and two team members. oracle.com/java8 Key Dates: Submissions begin March 3rd, 2014 Submission deadline is May 30th, 2014 Winners announced June 30th, 2014 JavaOne 2014 from Sept. 28 to Oct. 2, 2014
    10. 10. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.10 ■ An API included in Java SE 7/8 for UI development ■ The successor to Java Swing ■ Not the JavaFX Script language 10 JavaFX is:
    11. 11. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.11 Creating a User Interface
    12. 12. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.12 New JavaFX Application Dialog
    13. 13. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.13 Extend javafx.application.Application
    14. 14. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.14 Override the Application start() Method
    15. 15. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.15 Create the Circle
    16. 16. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.16 Create the Buttons and Handle Events
    17. 17. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.17 Layout the Buttons in an HBox
    18. 18. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.18 Create and Populate the Scene
    19. 19. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.19 Animate the Circle
    20. 20. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.20 Bind UI Properties to Animation Status
    21. 21. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.21 Setup and Show the Stage
    22. 22. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.22 Using Scene Builder and FXML
    23. 23. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.23 Scene Builder is a... ■ UI layout tool for JavaFX ■ Visual Editor for FXML
    24. 24. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.24 FXML is... ■ an XML-based language that expresses the UI ■ designed to be toolable
    25. 25. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.25 Download Scene Builder http://www.oracle.com/technetwork/java/javase/downloads
    26. 26. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.26 Scene Builder 2.0 Preview Available
    27. 27. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.27 Some New Java Features in JDK 8 ■ Nashorn JavaScript Engine ■ Date & Time API (JSR-310) ■ Bulk data operations for collections ■ Lambda expressions and virtual extension methods 27
    28. 28. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.28 Compact Profiles Approximate static footprint goals Compact1 Profile Compact2 Profile Compact3 Profile Full JRE 54Mb 30Mb 16Mb 11Mb
    29. 29. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.29 Java SE Embedded  Optimised binary for embedded use from devices to gateways  Latest Java innovations in the smallest footprint  Use of compact profiles – Approximate JRE size 20.4Mb (ARM v7 VFS, Hard Float)  Compact profile 1: 10.4Mb  JavaFX: 10Mb  Production ready binary for popular platforms that run Linux – ARM v6/7 with Hard floating point – Raspberry Pi is one of the reference platforms
    30. 30. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.30 A Lambda Expression (Closure) is… …a function that that may have parameters, an expression or block of code, optionally returning a value. 30 e -> anim.playFromStart()
    31. 31. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.31 31 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.
    32. 32. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.32 32 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.
    33. 33. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.33 33 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.
    34. 34. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.34 34 Lose the Parentheses When a lambda expression has a single parameter and its type is inferred, the parentheses are not required
    35. 35. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.35 35 Lose the Braces Because the block of code in our lambda expression contains only one statement, we can lose the braces.
    36. 36. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.36 void createUI() { Button button = new Button("Guess What I'm Thinking"); button.setOnAction(e -> guess(e)); // lambda only calls a method ... } void guess(ActionEvent event) { Button button = (Button) event.getSource(); button.setText("You love Lambda!"); } If a lambda only calls a method …
    37. 37. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.37 … you can use a method reference void createUI() { Button button = new Button("Guess What I'm Thinking"); button.setOnAction(this::guess); // use method reference ... } void guess(ActionEvent event) { Button button = (Button) event.getSource(); button.setText("You love Lambda!"); }
    38. 38. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.38 Four Kinds of Method References 1) Reference to a static method: ContainingClass::staticMethodName 2) Reference to an instance method of a particular object: ContainingObject::instanceMethodName 3) Reference to an instance method of an arbitrary object of a particular type: ContainingType::methodName 4) Reference to a constructor: ClassName::new
    39. 39. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.39 Another Method Reference Example FileFilter x = f -> f.canRead(); // lambda only calls a method FileFilter x = File::canRead(); // use method reference
    40. 40. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.40 JavaFXpert.com blog post with more detail 40
    41. 41. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.41 Project Nashorn
    42. 42. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.42 Nashorn var Rectangle = Java.type("javafx.scene.shape.Rectangle"); var Color = Java.type("javafx.scene.paint.Color"); var StackPane = Java.type("javafx.scene.layout.StackPane"); var Scene = Java.type("javafx.scene.Scene"); var RotateTransition = Java.type("javafx.animation.RotateTransition"); var Duration = Java.type("javafx.util.Duration");
    43. 43. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.43 Nashorn var rect = new Rectangle(); rect.width = 200; rect.height = 200; rect.stroke = Color.WHITE; rect.strokeWidth = 5; rect.fill = Color.ORANGE; rect.arcWidth = 20; rect.arcHeight = 20; var stack = new StackPane(rect); $STAGE.scene = new Scene(stack, 320, 240, Color.BLACK); var tx = new RotateTransition(Duration.seconds(5), rect); tx.toAngle = 360; tx.autoReverse = true; tx.cycleCount = RotateTransition.INDEFINITE; tx.play();
    44. 44. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.44 Nashorn: Launching JavaFX $JDK_HOME/bin/jjs -fx hello.js
    45. 45. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.45 Nashorn FX
    46. 46. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.46 New JavaFX Features in JDK 8 ■ New Modern Theme: Modena ■ Enhancements to Collections, Binding, Tasks and Services ■ Full screen improvements, new unified stage style, Swing integration improvements, rich text, and printing ■ DatePicker and TreeTableView ■ Public API for CSS structure ■ WebView Enhancements ■ JavaFX 3D, Multi-touch (in 7 but relevant to 3D) ■ Embedded Support 46
    47. 47. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.47 JavaFX 8 New Theme Caspian vs Modena
    48. 48. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.48 Modena
    49. 49. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.49 Modena
    50. 50. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.50 JavaFX 8  Customisable – Configurable key combinations to exit full screen mode – Ability to prevent user exiting full screen mode Improvements To Full Screen Mode // Set the key combination that the user can use to exit stage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH); // Setup the click handler so we can escape from full screen Rectangle r = new Rectangle(0, 0, 250, 250); r.setOnMouseClicked(e -> stage.setFullScreen(false)); // Set full screen again stage.setFullScreen(true);
    51. 51. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.51 JavaFX 8  New API for printing – Currently only supported on desktop  Any node can be printed Printing Support PrinterJob job = PrinterJob.createPrinterJob(printer); job.getJobSettings().setPageLayout(pageLayout); job.getJobSettings().setPrintQuality(PrintQuality.HIGH); job.getJobSettings().setPaperSource(PaperSource.MANUAL); job.getJobSettings().setCollation(Collation.COLLATED); if (job.printPage(someRichText)) job.endJob();
    52. 52. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.52 JavaFX 8  DatePicker  TreeTableView New Controls
    53. 53. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.53 java.time DatePicker
    54. 54. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.54 54 DatePicker
    55. 55. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.55 DatePicker import java.time.LocalDate; // From new Date/Time API ... LocalDate ld; DatePicker dp = new DatePicker(); dp.setOnAction(e -> { ld = dp.getValue(); System.out.println("Date selected " + ld); });
    56. 56. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.56 Date Picker
    57. 57. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.57 TreeTableView UI control with combined TreeView and TableView controls functionality 57
    58. 58. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.58 JavaFX 8  Gestures – Swipe – Scroll – Rotate – Zoom  Touch events and touch points Touch Support
    59. 59. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.59 Touch Gestures
    60. 60. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.60 The Swipe Gesture  Commonly a finger drag in one direction  A single event is produced for the gesture  May be left, right, up, or down
    61. 61. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.61 Handling the Swipe Gesture (SwipeEvent) Note: Lambda expressions from JDK 8 are used here to simplify event handling
    62. 62. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.62 Handling the Swipe Gesture (SwipeEvent)
    63. 63. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.63 The Scroll Gesture  User turns mouse wheel, drags finger on touch screen, etc.  Scroll events are continuously generated, containing x/y position-related info  Events are pixel-based or character/line- based  If inertia is supported, scroll events may be generated after user quits scrolling
    64. 64. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.64 Handling the Scroll Gesture (ScrollEvent)
    65. 65. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.65 The Rotate Gesture  User typically drags two fingers around each other  Rotate events are continuously generated, containing angle-related info
    66. 66. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.66 Handling the Rotate Gesture (RotateEvent)
    67. 67. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.67 The Zoom Gesture  User typically drags two fingers apart or closer together  Zoom events are continuously generated, containing zoom factor-related info
    68. 68. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.68 Handling the Zoom Gesture (ZoomEvent)
    69. 69. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.69 Handling Touch (TouchEvent/TouchPoint)  A TouchEvent contains information about a touch, including: – Event type: Pressed, released, moved, or stationary – Touch points: The TouchPoint instances that represent each of the points that were touched  Each TouchEvent has a unique ID to identify the events and touch points in a multi-touch action
    70. 70. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.70 Responding to Touch Events
    71. 71. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.71 JavaFX 8  Predefined shapes – Box – Cylinder – Sphere  User-defined shapes – TriangleMesh, MeshView  PhongMaterial  Lighting  Cameras 3D Support
    72. 72. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.72 72 Creating Primitive Shapes and Materials
    73. 73. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.73 Placing a Texture on a Sphere 73
    74. 74. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.74 Placing a Texture on a Sphere 74
    75. 75. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.75 3D Lights ■ Lights are nodes in the scene graph ■ PointLight ■ AmbientLight ■ Default light provided if no active lights 75
    76. 76. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.76 76 Lights, Camera, Action!
    77. 77. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.77 Example 3D multi-touch app: ZenGuitar3D
    78. 78. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.78 Questions?
    79. 79. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.79 79 Please note 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.
    80. 80. New JavaFX Features in Java 8 (and an intro to Lambdas) James Weaver Java Technology Ambassador Oracle Corporation @JavaFXpert james.weaver@oracle.com
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×