750 likes | 1.04k Views
New JavaFX Features in JDK 8 (after a gentle intro to app development with JavaFX ). Jim Weaver Java Technology Ambassador Oracle Corporation @ JavaFXpert james.weaver@oracle.com. Intro to app development with JavaFX Obtaining JavaFX resources Creating a user interface
E N D
New JavaFX Features in JDK 8(after a gentle intro to app development with JavaFX) Jim Weaver Java Technology Ambassador Oracle Corporation @JavaFXpert james.weaver@oracle.com
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 ProgramAgenda
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. 3
JavaFX is: • An API included in Java SE 7/8 for UI development • The successor to Java Swing • Not the JavaFX Script language 4
Download JDK 7 + NetBeans http://www.oracle.com/technetwork/java/javase/downloads 8
Get Pro JavaFX 2 Book Resources First chapter and all code samples available at http://ProJavaFX2.com for free 11
Visit Here: http://fxexperience.com Tip: This site is authored by Oracle JavaFX Engineers 12
Scene Builder is a... • UI layout tool for JavaFX • Visual Editor for FXML
FXML is... • an XML-based language that expresses the UI • designed to be toolable
Download Scene Builder http://www.oracle.com/technetwork/java/javase/downloads
Metronome Example w/Scene Builder In NetBeans create a New Project of type “JavaFX FXML Application”
In the New JavaFX Application Dialog... We’ll use MetronomeTransitionFXML for the Project Name and FXML Name
Open the FXML File in Scene Builder... ...by double-clicking it in the project tree
Some New Java Features in JDK 8 Nashorn JavaScript Engine Date & Time API Bulk data operations for collections Lambda expressions and virtual extension methods 46
A Lambda Expression (Closure) is… …a function that that may have parameters, an expression or block of code, optionally returning a value. e -> anim.playFromStart() 47
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. 48
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. 49
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. 50