1 / 75

New JavaFX Features in JDK 8 (after a gentle intro to app development with JavaFX )

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

eros
Download Presentation

New JavaFX Features in JDK 8 (after a gentle intro to app development with JavaFX )

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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

  2. 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

  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. 3

  4. JavaFX is: • An API included in Java SE 7/8 for UI development • The successor to Java Swing • Not the JavaFX Script language 4

  5. To Get JavaFX, Download Java 7

  6. To Develop JavaFX, Use Your Fav IDE

  7. Start Here: http://javafxcommunity.com 7

  8. Download JDK 7 + NetBeans http://www.oracle.com/technetwork/java/javase/downloads 8

  9. Download Samples (e.g. Ensemble) 9

  10. Ensemble in Mac App Store

  11. Get Pro JavaFX 2 Book Resources First chapter and all code samples available at http://ProJavaFX2.com for free 11

  12. Visit Here: http://fxexperience.com Tip: This site is authored by Oracle JavaFX Engineers 12

  13. Creating a User Interface

  14. New JavaFX Application Dialog

  15. Extend javafx.application.Application

  16. Override the Application start() Method

  17. Create the Circle

  18. Create the Buttons and Handle Events

  19. Layout the Buttons in an HBox

  20. Create and Populate the Scene

  21. Animate the Circle

  22. Bind UI Properties to Animation Status

  23. Setup and Show the Stage

  24. Using Scene Builder and FXML

  25. Scene Builder is a... • UI layout tool for JavaFX • Visual Editor for FXML

  26. FXML is... • an XML-based language that expresses the UI • designed to be toolable

  27. Download Scene Builder http://www.oracle.com/technetwork/java/javase/downloads

  28. Metronome Example w/Scene Builder In NetBeans create a New Project of type “JavaFX FXML Application”

  29. In the New JavaFX Application Dialog... We’ll use MetronomeTransitionFXML for the Project Name and FXML Name

  30. Open the FXML File in Scene Builder... ...by double-clicking it in the project tree

  31. Let’s Make it Look Like the Metronome...

  32. Make the Stage Taller...

  33. Delete the Existing Controls...

  34. Drag Four Buttons on the Stage...

  35. Arrange > Wrap in > HBox...

  36. Drag HBox into Desired Position...

  37. Drag a Circle to the Stage...

  38. Edit Circle Properties/Layout Inspectors...

  39. Add Fields to the Controller

  40. Add Handlers to the Controller

  41. Populate Controller initialize Method

  42. Modify Buttons’ Properties Inspectors...

  43. Modify Buttons’ Code Inspectors...

  44. Modify Circle’s Properties Inspector...

  45. Run the MetronomeTransitionFXML App

  46. 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

  47. 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

  48. 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

  49. 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

  50. 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

More Related