Download - JavaFX 2 Using the Spring Framework
![Page 1: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/1.jpg)
1 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
JavaFX 2 Using the Spring Framework
Presented by Stephen Chin <@steveonjava>
![Page 2: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/2.jpg)
2 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
About the Presenter: Stephen Chin
• Oracle Java/JavaFX Evangelist
• Authored several books, most recently Pro JavaFX 2
• Wrote the JavaFX 1 & 2 Refcard
• Blog: steveonjava.com
• Twitter: @steveonjava
• E-mail: [email protected]
![Page 3: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/3.jpg)
3 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Safe Harbor Statement
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.
![Page 4: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/4.jpg)
4 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
JavaFX Resources
• Visit ProJavaFX2.com to download Chapter 1 and all code examples
• JavaFX site: oracle.com/javafx
• NetBeans site: netbeans.org
• FXExperience blog: fxexperience.com
• Jim Weaver’s JavaFX blog: JavaFXpert.com
• My JavaFX blog: steveonjava.com
![Page 5: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/5.jpg)
5 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
What I want you to take away
1. The JRE with JavaFX enables graphically rich, fast performing applications
2. Developing JavaFX apps is natural and fun
3. You can build robust business applications using the Spring Framework and JavaFX
4. You should begin playing with JavaFX and Spring now!
![Page 6: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/6.jpg)
6 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
1. Getting Started with JavaFX
• Bringing back rich-client Java
• Learning the history of JavaFX
• Obtaining JavaFX tools and resources
• Building and running Hello EarthRise
• Reviewing the structure of Hello EarthRise
![Page 7: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/7.jpg)
7 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Bringing back rich-client Java
• The web, originally intended for sharing hypertext-linked resources, has been force-fit into being a rich-client platform
• The JRE with JavaFX is a much better client platform, enabling graphically rich, fast performing applications
• See Chapter 1 JavaFX Can’t Bring Rich-Client Java Back by Itself section
![Page 8: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/8.jpg)
8 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Learning the history of JavaFX
• The brainchild of Chris Oliver while at SeeBeyond, which was acquired by Sun
• JavaFX Script language and platform announced at JavaOne 2007
• Oracle implemented JavaFX 2 as an API for Java, announced at JavaOne 2010
• JavaFX 2.1 GA released for JavaOne India 2012– Windows and OS/X now GA, Linux GA soon
• See Chapter 1 A Brief History of JavaFX section
![Page 9: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/9.jpg)
9 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Obtaining JavaFX tools and resources
• Visit oracle.com/javafx and click Download
• Grab the co-bundled Java SE 7u6, JavaFX 2.2 and NetBeans 7.2
• Note: Java SE 7u4+ bundles JavaFX 2.1
![Page 10: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/10.jpg)
10 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Building and running Hello EarthRise
• Follow the steps in Chapter 1 Building and Running the Program with NetBeans section
![Page 11: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/11.jpg)
11 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Demo
![Page 12: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/12.jpg)
12 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Review the structure of Hello Earthrise
• Application class and overriden start()
• Declarative code that defines the UI
• Using the Stage class
• Using the Scene class
• Displaying images
• See Chapter 1 Understanding the Hello Earthrise Program section
![Page 13: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/13.jpg)
13 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Code Walkthru
![Page 14: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/14.jpg)
14 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
2. Using the JavaFX UI Controls
• Demo the StarterApp example
• Examine the StarterApp code
• Survey UI controls in StarterApp
• Leveraging the UI controls in code
• Associating a JavaFX CSS style sheet
• Defining model classes
![Page 15: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/15.jpg)
15 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Demo the StarterApp example
• StarterApp code is in the 8727_ch05code folder of the Pro JavaFX 2 code download bundle
![Page 16: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/16.jpg)
16 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Demo
![Page 17: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/17.jpg)
17 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Examine StarterApp code
• Survey UI controls in StarterApp
• Leveraging the UI controls in code
• Associating a JavaFX CSS style sheet
• Defining model classes
![Page 18: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/18.jpg)
18 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Code Walkthru
![Page 19: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/19.jpg)
19 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
3. Using Media Classes with Spring
• Demo the SpringVideoPlayer example
• Examine the SpringVideoPlayer code
• Using the MediaView, MediaPlayer and Media classes
• Configuring and loading the Spring context
![Page 20: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/20.jpg)
20 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Demo the SpringVideoPlayer example
![Page 21: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/21.jpg)
21 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Demo
![Page 22: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/22.jpg)
22 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Examine SpringVideoPlayer code
• Using the MediaView, MediaPlayer and Media classes
• Using a procedural vs. declarative approach
![Page 23: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/23.jpg)
23 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Spring Context and Configuration
SpringVideoPlayer
• Starts the JavaFX App Thread
• Loads the Spring Context
VideoConfiguration
• Loads the Media as a Spring Bean
• Creates the Screen UI a a Spring Bean
MediaPlayerScreen
• Wraps the MediaView
• Exposes MediaPlayer controls
![Page 24: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/24.jpg)
24 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Code Walkthru
![Page 25: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/25.jpg)
25 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
4. Spring Data and Security
• Show the CustomerService backend
• Show the CustomerDataApp frontend
• Demonstrate Spring security to enforce permissions on the client
Special thanks to Josh Long (@starbuxman) for help with this application
![Page 26: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/26.jpg)
26 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Customer Data Application
![Page 27: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/27.jpg)
27 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Demo
![Page 28: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/28.jpg)
28 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
5. Using SceneBuilder
• Show the SceneBuilder tool
• Create a new application from scratch in SceneBuilder
• Integrate in a Spring/JavaFX application
• Show how to hook up a JavaFX Controller
![Page 29: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/29.jpg)
29 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Building UIs with SceneBuilder
![Page 30: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/30.jpg)
30 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Demo
![Page 31: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/31.jpg)
31 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
6. Deploying JavaFX apps
• Some options are Java WebStart and running as an applet– e.g. Icon at well-known web page that
invokes TweetBrowser via Java WebStart
• Another good deployment option is creating an installer – “there’s an app for that”– See related FXexperience.com blog post– Packager available in JavaFX 2.2
![Page 32: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/32.jpg)
32 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Take-aways from this presentation
1. The JRE with JavaFX enables graphically rich, fast performing applications
2. Developing JavaFX apps is natural, fun, and even faster using SceneBuilder
3. You can use Spring on the backend to provide a web service API
4. You can also use Spring on the frontend for beans, dependency injection, and security
5. You should begin playing with JavaFX and Spring now!
![Page 33: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/33.jpg)
33 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Q&A
![Page 34: JavaFX 2 Using the Spring Framework](https://reader037.vdocuments.site/reader037/viewer/2022102804/54c677034a7959a4368b4577/html5/thumbnails/34.jpg)
34 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8