SlideShare a Scribd company logo
JavaFX 2 – A Java Developer's Guide
Presented by Stephen Chin <@steveonjava>
 1   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
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: stephen.chin@oracle.com

2   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
    reserved.
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.



3   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
    reserved.
Lab 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




4   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
    reserved.
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. Lots of great resources exist to help you
       get started with JavaFX
    4. You should begin playing with JavaFX
       now!


5   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
    reserved.
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




6   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
    reserved.
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

7   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
    reserved.
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
    • See Chapter 1 A Brief History of JavaFX section



8   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
    reserved.
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




9   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
    reserved.
Building and running Hello EarthRise

     • Follow the steps in Chapter 1 Building and Running
       the Program with NetBeans section




10   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
Demo


11   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
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

12   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
Code Walkthru


13   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
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



14   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
Demo the StarterApp example


                                                                                                                                     • StarterApp code
                                                                                                                                       is in the
                                                                                                                                       8727_ch05code
                                                                                                                                       folder of the Pro
                                                                                                                                       JavaFX 2 code
                                                                                                                                       download bundle




15   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
Demo


16   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
Examine StarterApp code

     •   Survey UI controls in StarterApp
     •   Leveraging the UI controls in code
     •   Associating a JavaFX CSS style sheet
     •   Defining model classes




17   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
Code Walkthru


18   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
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



19   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
Demo the SpringVideoPlayer example




20   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
Demo


21   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
Examine SpringVideoPlayer code

     • Using the MediaView, MediaPlayer and
       Media classes
     • Using a procedural vs. declarative
       approach




22   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
Spring Context and Configuration



          SpringVideoPlayer                                                           VideoConfiguration                             MediaPlayerScreen

     • Starts the JavaFX                                                            • Loads the Media                                • Wraps the
       App Thread                                                                     as a Spring Bean                                 MediaView
     • Loads the Spring                                                             • Creates the                                    • Exposes
       Context                                                                        Screen UI a a                                    MediaPlayer
                                                                                      Spring Bean                                      controls



23   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
Code Walkthru


24   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
4. Using SceneBuilder

     • Show the SceneBuilder tool
     • Create a new application from scratch in
       SceneBuilder
     • Show how to hook up a JavaFX Controller




25   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
Building UIs with SceneBuilder




26   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
Demo


27   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
5. 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

28   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
6. Embedding HTML5

     • Show the WebView API
     • Demo the Java Conference Tour example
     • Examine the Java Conference Tour
       architecture




29   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
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();
     }}


30   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
Displaying HTML in JavaFX




31   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
Calling Javascript from JavaFX

     String script = "alert('We have got a message, Houston!');”;
     eng.executeScript(script);




32   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
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



   33   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
        reserved.
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

34   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
The Java Conference Tour app




35   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
Demo


36   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
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 the best parts of JavaFX and
        HTML5 together in the same application
     4. Lots of great resources exist to help you
        get started with JavaFX
     5. You should begin playing with JavaFX
37
        now!
     Copyright © 2011, Oracle and/or its affiliates. All rights
     reserved.
                                                                  Insert Information Protection Policy Classification from Slide 8
Come to JavaOne Embedded @ JavaOne

     • New JavaOne Subconf
     • Focused on the rapidly
       growing embedded market
     • Early bird registration still
       open!
     • Only $100 if you are already
       coming to JavaOne

       http://www.oracle.com/javaone/embedded
38   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
Q&A


39   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.
40   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
     reserved.

More Related Content

What's hot (20)

PDF
Burns jsf-confess-2015
Edward Burns
 
PDF
2015 JavaOne LAD JSF 2.3 & MVC 1.0
mnriem
 
PPTX
Ed presents JSF 2.2 at a 2013 Gameduell Tech talk
Edward Burns
 
PPTX
Migrating From Applets to Java Desktop Apps in JavaFX
Bruno Borges
 
ODT
Spring framework
Shivi Kashyap
 
PDF
JSF 2.2 Input Output JavaLand 2015
Edward Burns
 
PPT
What's New in WebLogic 12.1.3 and Beyond
Oracle
 
PDF
JavaOne2015報告会 in Okinawa
Takashi Ito
 
PDF
How to Thrive on REST/WebSocket-Based Microservices
Pavel Bucek
 
PDF
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
David Delabassee
 
PPTX
Java spring ppt
natashasweety7
 
PDF
Java EE 7 from an HTML5 Perspective, JavaLand 2015
Edward Burns
 
PDF
Building Secure Mashups With OpenAjax
elliando dias
 
PPTX
EE4J: Java EE & Jakarta EE JFR & JMC
M. Fevzi Korkutata
 
PPTX
Java Spring
AathikaJava
 
PPTX
Java Spring Framework
Mehul Jariwala
 
PPTX
Ed presents JSF 2.2 and WebSocket to Gameduell.
Edward Burns
 
PPTX
Tecnologias Oracle em Docker Containers On-premise e na Nuvem
Bruno Borges
 
PDF
Modules all the way down: OSGi and the Java Platform Module System
Tim Ellison
 
PPTX
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
Mert Çalışkan
 
Burns jsf-confess-2015
Edward Burns
 
2015 JavaOne LAD JSF 2.3 & MVC 1.0
mnriem
 
Ed presents JSF 2.2 at a 2013 Gameduell Tech talk
Edward Burns
 
Migrating From Applets to Java Desktop Apps in JavaFX
Bruno Borges
 
Spring framework
Shivi Kashyap
 
JSF 2.2 Input Output JavaLand 2015
Edward Burns
 
What's New in WebLogic 12.1.3 and Beyond
Oracle
 
JavaOne2015報告会 in Okinawa
Takashi Ito
 
How to Thrive on REST/WebSocket-Based Microservices
Pavel Bucek
 
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
David Delabassee
 
Java spring ppt
natashasweety7
 
Java EE 7 from an HTML5 Perspective, JavaLand 2015
Edward Burns
 
Building Secure Mashups With OpenAjax
elliando dias
 
EE4J: Java EE & Jakarta EE JFR & JMC
M. Fevzi Korkutata
 
Java Spring
AathikaJava
 
Java Spring Framework
Mehul Jariwala
 
Ed presents JSF 2.2 and WebSocket to Gameduell.
Edward Burns
 
Tecnologias Oracle em Docker Containers On-premise e na Nuvem
Bruno Borges
 
Modules all the way down: OSGi and the Java Platform Module System
Tim Ellison
 
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
Mert Çalışkan
 

Viewers also liked (17)

PDF
Design Patterns Presentation - Chetan Gole
Chetan Gole
 
PPT
Design patterns ppt
Aman Jain
 
PDF
Java FX 2.0 - A Developer's Guide
Stephen Chin
 
PPTX
Raspberry pi gaming 4 kids
Stephen Chin
 
PDF
Raspberry Pi Gaming 4 Kids - Dutch Version
Stephen Chin
 
PPTX
RetroPi Handheld Raspberry Pi Gaming Console
Stephen Chin
 
PPTX
Raspberry Pi Gaming 4 Kids (Devoxx4Kids)
Stephen Chin
 
PPTX
Confessions of a Former Agile Methodologist (JFrog Edition)
Stephen Chin
 
PPTX
Oracle IoT Kids Workshop
Stephen Chin
 
PPTX
Devoxx4Kids NAO Workshop
Stephen Chin
 
PPTX
Devoxx4Kids Lego Workshop
Stephen Chin
 
KEY
Java Fx - Return of client Java
Shuji Watanabe
 
PDF
8 True Stories about JavaFX
Yuichi Sakuraba
 
PPTX
JavaFX Presentation
Mochamad Taufik Mulyadi
 
PDF
Design patterns
abhisheksagi
 
PPTX
Uml Presentation
mewaseem
 
PPTX
Software design patterns ppt
mkruthika
 
Design Patterns Presentation - Chetan Gole
Chetan Gole
 
Design patterns ppt
Aman Jain
 
Java FX 2.0 - A Developer's Guide
Stephen Chin
 
Raspberry pi gaming 4 kids
Stephen Chin
 
Raspberry Pi Gaming 4 Kids - Dutch Version
Stephen Chin
 
RetroPi Handheld Raspberry Pi Gaming Console
Stephen Chin
 
Raspberry Pi Gaming 4 Kids (Devoxx4Kids)
Stephen Chin
 
Confessions of a Former Agile Methodologist (JFrog Edition)
Stephen Chin
 
Oracle IoT Kids Workshop
Stephen Chin
 
Devoxx4Kids NAO Workshop
Stephen Chin
 
Devoxx4Kids Lego Workshop
Stephen Chin
 
Java Fx - Return of client Java
Shuji Watanabe
 
8 True Stories about JavaFX
Yuichi Sakuraba
 
JavaFX Presentation
Mochamad Taufik Mulyadi
 
Design patterns
abhisheksagi
 
Uml Presentation
mewaseem
 
Software design patterns ppt
mkruthika
 
Ad

Similar to JavaFX 2 - A Java Developer's Guide (San Antonio JUG Version) (20)

PPTX
Introduction To JavaFX 2.0
Boulder Java User's Group
 
PPTX
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
JAX London
 
PPT
What is java fx?
kanchanmahajan23
 
PDF
JavaFX 2 Rich Desktop Platform
Rajmahendra Hegde
 
PDF
Beyond The Buzz: Pluggable JavaFX Corporate Applications
JAX London
 
PDF
JavaFX Advanced
Paul Bakker
 
PDF
Hinkmond's JavaFX Mobile Dojo
Stephen Chin
 
PPTX
A Importância do JavaFX no Mercado Embedded
Bruno Borges
 
PDF
The Brainify App - JavaFx
Mohd Shamweel
 
PPT
JavaFX - Next Generation Java UI
Yoav Aharoni
 
PDF
Java keynote preso
Artur Alves
 
PPTX
JavaFX and WidgetFX at SVCodeCamp
Stephen Chin
 
PPTX
OpenJFX on Android and Devices
Stephen Chin
 
PDF
JavaFX 101
Richard Bair
 
PDF
[English version] JavaFX and Web Integration
Kazuchika Sekiya
 
PDF
Os Ramani
oscon2007
 
PDF
JavaOne - The JavaFX Community and Ecosystem
Alexander Casall
 
PPTX
Complete Solution for JavaFX Development - NexSoftSys
NexSoftsys
 
DOCX
What is java fx?
kanchanmahajan23
 
ODP
Javafx
Rahul karan
 
Introduction To JavaFX 2.0
Boulder Java User's Group
 
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
JAX London
 
What is java fx?
kanchanmahajan23
 
JavaFX 2 Rich Desktop Platform
Rajmahendra Hegde
 
Beyond The Buzz: Pluggable JavaFX Corporate Applications
JAX London
 
JavaFX Advanced
Paul Bakker
 
Hinkmond's JavaFX Mobile Dojo
Stephen Chin
 
A Importância do JavaFX no Mercado Embedded
Bruno Borges
 
The Brainify App - JavaFx
Mohd Shamweel
 
JavaFX - Next Generation Java UI
Yoav Aharoni
 
Java keynote preso
Artur Alves
 
JavaFX and WidgetFX at SVCodeCamp
Stephen Chin
 
OpenJFX on Android and Devices
Stephen Chin
 
JavaFX 101
Richard Bair
 
[English version] JavaFX and Web Integration
Kazuchika Sekiya
 
Os Ramani
oscon2007
 
JavaOne - The JavaFX Community and Ecosystem
Alexander Casall
 
Complete Solution for JavaFX Development - NexSoftSys
NexSoftsys
 
What is java fx?
kanchanmahajan23
 
Javafx
Rahul karan
 
Ad

More from Stephen Chin (20)

PPTX
DevOps Tools for Java Developers v2
Stephen Chin
 
PPTX
10 Ways Everyone Can Support the Java Community
Stephen Chin
 
PPTX
Java Clients and JavaFX: The Definitive Guide
Stephen Chin
 
PPTX
DevOps Tools for Java Developers
Stephen Chin
 
PPTX
Java Clients and JavaFX - Presented to LJC
Stephen Chin
 
PPTX
JavaFX on Mobile (by Johan Vos)
Stephen Chin
 
PPTX
Raspberry Pi with Java (JJUG)
Stephen Chin
 
PPTX
Confessions of a Former Agile Methodologist
Stephen Chin
 
PPTX
Internet of Things Magic Show
Stephen Chin
 
PPTX
Zombie Time - JSR 310 for the Undead
Stephen Chin
 
PPTX
JCrete Embedded Java Workshop
Stephen Chin
 
PPTX
Java on Raspberry Pi Lab
Stephen Chin
 
PDF
Java 8 for Tablets, Pis, and Legos
Stephen Chin
 
PDF
DukeScript
Stephen Chin
 
PDF
Mary Had a Little λ (QCon)
Stephen Chin
 
PPTX
Raspberry Pi à la GroovyFX
Stephen Chin
 
PPTX
LUGOD Raspberry Pi Hacking
Stephen Chin
 
PPTX
Moving to the Client - JavaFX and HTML5
Stephen Chin
 
PPTX
Hacking JavaFX with Groovy, Clojure, Scala, and Visage
Stephen Chin
 
PPTX
JavaFX and Scala in the Cloud
Stephen Chin
 
DevOps Tools for Java Developers v2
Stephen Chin
 
10 Ways Everyone Can Support the Java Community
Stephen Chin
 
Java Clients and JavaFX: The Definitive Guide
Stephen Chin
 
DevOps Tools for Java Developers
Stephen Chin
 
Java Clients and JavaFX - Presented to LJC
Stephen Chin
 
JavaFX on Mobile (by Johan Vos)
Stephen Chin
 
Raspberry Pi with Java (JJUG)
Stephen Chin
 
Confessions of a Former Agile Methodologist
Stephen Chin
 
Internet of Things Magic Show
Stephen Chin
 
Zombie Time - JSR 310 for the Undead
Stephen Chin
 
JCrete Embedded Java Workshop
Stephen Chin
 
Java on Raspberry Pi Lab
Stephen Chin
 
Java 8 for Tablets, Pis, and Legos
Stephen Chin
 
DukeScript
Stephen Chin
 
Mary Had a Little λ (QCon)
Stephen Chin
 
Raspberry Pi à la GroovyFX
Stephen Chin
 
LUGOD Raspberry Pi Hacking
Stephen Chin
 
Moving to the Client - JavaFX and HTML5
Stephen Chin
 
Hacking JavaFX with Groovy, Clojure, Scala, and Visage
Stephen Chin
 
JavaFX and Scala in the Cloud
Stephen Chin
 

Recently uploaded (20)

PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
July Patch Tuesday
Ivanti
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
July Patch Tuesday
Ivanti
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 

JavaFX 2 - A Java Developer's Guide (San Antonio JUG Version)

  • 1. JavaFX 2 – A Java Developer's Guide Presented by Stephen Chin <@steveonjava> 1 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 2. 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] 2 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 3. 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. 3 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 4. Lab 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 4 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 5. 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. Lots of great resources exist to help you get started with JavaFX 4. You should begin playing with JavaFX now! 5 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 6. 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 6 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 7. 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 7 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 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 • See Chapter 1 A Brief History of JavaFX section 8 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 9. 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 9 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 10. Building and running Hello EarthRise • Follow the steps in Chapter 1 Building and Running the Program with NetBeans section 10 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 11. Demo 11 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 12. 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 12 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 13. Code Walkthru 13 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 14. 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 14 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 15. Demo the StarterApp example • StarterApp code is in the 8727_ch05code folder of the Pro JavaFX 2 code download bundle 15 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 16. Demo 16 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 17. Examine StarterApp code • Survey UI controls in StarterApp • Leveraging the UI controls in code • Associating a JavaFX CSS style sheet • Defining model classes 17 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 18. Code Walkthru 18 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 19. 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 19 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 20. Demo the SpringVideoPlayer example 20 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 21. Demo 21 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 22. Examine SpringVideoPlayer code • Using the MediaView, MediaPlayer and Media classes • Using a procedural vs. declarative approach 22 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 23. Spring Context and Configuration SpringVideoPlayer VideoConfiguration MediaPlayerScreen • Starts the JavaFX • Loads the Media • Wraps the App Thread as a Spring Bean MediaView • Loads the Spring • Creates the • Exposes Context Screen UI a a MediaPlayer Spring Bean controls 23 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 24. Code Walkthru 24 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 25. 4. Using SceneBuilder • Show the SceneBuilder tool • Create a new application from scratch in SceneBuilder • Show how to hook up a JavaFX Controller 25 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 26. Building UIs with SceneBuilder 26 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 27. Demo 27 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 28. 5. 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 28 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 29. 6. Embedding HTML5 • Show the WebView API • Demo the Java Conference Tour example • Examine the Java Conference Tour architecture 29 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 30. 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(); }} 30 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 31. Displaying HTML in JavaFX 31 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 32. Calling Javascript from JavaFX String script = "alert('We have got a message, Houston!');”; eng.executeScript(script); 32 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 33. 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 33 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 34. 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 34 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 35. The Java Conference Tour app 35 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 36. Demo 36 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 37. 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 the best parts of JavaFX and HTML5 together in the same application 4. Lots of great resources exist to help you get started with JavaFX 5. You should begin playing with JavaFX 37 now! Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 38. Come to JavaOne Embedded @ JavaOne • New JavaOne Subconf • Focused on the rapidly growing embedded market • Early bird registration still open! • Only $100 if you are already coming to JavaOne http://www.oracle.com/javaone/embedded 38 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 39. Q&A 39 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.
  • 40. 40 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved.