SlideShare ist ein Scribd-Unternehmen logo
1 von 37
JavaFX
Rich Internet Application with Java




                                      copyright 2008 trainologic LTD
JavaFX



• Introduction.
• The Scripting Language.
• UI - The Scene Graph.
• Deployment.




                            copyright 2008 trainologic LTD
JavaFX



                  What is JavaFX?

• Started from the F3 project developed by Chris Oliver.
• Java’s Rich Internet Application Platform.
• Direct Competition with Adobe Flash/Flex/Air.
• Direct competition with MS Silverlite.




                             3
                                                  copyright 2008 trainologic LTD
JavaFX



                What is JavaFX?

  A platform and tools suite that offers distinct
  advantages to Web developers, Web designers, and
  Java developers who are building rich, connected
  experiences.




                          4
                                             copyright 2008 trainologic LTD
JavaFX



                  What is JavaFX?

• Composed of a simple scripting language, combined
  with enhanced graphics abilities.

• Tools that help designers and developers work closer
  together.

• Runs on the JVM.
• Deploys easily to the desktop, browser.
• Future releases are planed to support Mobile Phones
  and TV.



                             5
                                               copyright 2008 trainologic LTD
JavaFX



         What is JavaFX?




                6
                           copyright 2008 trainologic LTD
JavaFX



• Introduction.
• The Scripting Language.
• UI - The Scene Graph.
• Deployment.




                            copyright 2008 trainologic LTD
JavaFX



         The JavaFX Scripting Language

• As the name suggests, it is a scripting language.
• Unlike many other scripting languages, it is a compiled
  language.
• As you probably guessed, it is compiling to Java
  Classes.

• Unlike Java, it has a handful of tricks that makes the
  development really easy... We will cover some of them.




                             8
                                                 copyright 2008 trainologic LTD
JavaFX



         The JavaFX Scripting Language

• Let’s dive into the water...


     result = add(1, 2);
     println(quot;1 + 2 = {result}quot;);


     function add(numOne:Integer, numTwo:Integer):Integer {
          var result = numOne + numTwo;
          return result;
     }




                                 9
                                                       copyright 2008 trainologic LTD
JavaFX



         The JavaFX Scripting Language

• So... What do we have here?
• Code out of a class.
• Untyped variables.
• Special String literal.
• There is much more...




                            10
                                    copyright 2008 trainologic LTD
JavaFX



         The JavaFX Scripting Language

• Declaring a class:


     class Customer {
          var firstName: String;
          var lastName: String;
          var phoneNum: String;
          var address: Address;

         function printName() {
             println(quot;Name: {firstName} {lastName}quot;);
         }




                               11
                                                        copyright 2008 trainologic LTD
JavaFX



         The JavaFX Scripting Language

• Object literals:

     def customer = Customer {
          firstName: quot;Johnquot;;
          lastName: quot;Doequot;;
          phoneNum: quot;(408) 555-1212quot;;
          address: Address {
               street: quot;1 Main Streetquot;;
               city: quot;Santa Claraquot;;
               state: quot;CAquot;;
               zip: quot;95050quot;;
          }
     }




                                12
                                          copyright 2008 trainologic LTD
JavaFX



         The JavaFX Scripting Language

• The basic data types:
      String - “Hello”, ‘Hello’, “Hello {expression}”
  •

      Number - 4.2
  •

      Integer - 3
  •

      Boolean - true, false
  •

      Duration - 10ms, 5s, 3m, 1h
  •

      Void - just like Java, but written with upper-case.
  •

      null - just the same as in Java.
  •


                                13
                                                        copyright 2008 trainologic LTD
JavaFX



         The JavaFX Scripting Language

• Sequences:

         // Sequence Literal
         var weekDays: String[] = [quot;Monquot;,quot;Tuequot;,quot;Wedquot;,quot;Thuquot;,quot;Friquot;];

         // Sequence Concatenation
         var days = [weekDays, [quot;Satquot;,quot;Sunquot;]];

         // Sequence ranges
         var nums = [1..100]
         var nums = [1..100 step 2] // 1, 3, 5, ...99

         // Sequence Querying
         var numsGreaterThanTwo = nums[n | n > 2]; // 3, 4, 5 ...100




                                    14
                                                               copyright 2008 trainologic LTD
JavaFX



         The JavaFX Scripting Language

• Block Expression - Returns the value of the last
  expression in the block.



         var nums = [5,   7, 3, 9];
         var total = {
              var sum =   0;
              for (a in   nums) { sum += a };
              sum;
         }
         println(quot;Total   is {total}.quot;);




                                      15
                                                copyright 2008 trainologic LTD
JavaFX



         The JavaFX Scripting Language

• Another cool feature in JavaFX is data binding.
• Data binding means binding the value of one variable
  to another.
• When the first changes it changes the second as well.
• Objects and methods can also be bound.
• Let’s take a look...




                            16
                                                    copyright 2008 trainologic LTD
JavaFX



         The JavaFX Scripting Language

• Binding two variables, not so impressive...


          var x = 0;
          def y = bind x;

          x = 1;
          println(y); // y now equals 1

          x = 47;
          println(y); // y now equals 47




                                 17
                                                copyright 2008 trainologic LTD
JavaFX



             The JavaFX Scripting Language

 • Binding an object, starting to get more interesting...

var   myStreet = quot;1 Main Streetquot;;
var   myCity = quot;Santa Claraquot;;
var   myState = quot;CAquot;;
var   myZip = quot;95050quot;;

def address = bind Address {
     street: myStreet;
     city: myCity;
     state: myState;
     zip: myZip;
};

println(quot;address.street == {address.street}quot;); // 1 Main Street
myStreet = quot;100 Maple Streetquot;;
println(quot;address.street == {address.street}quot;); // 100 Maple Street




                                      18
                                                                 copyright 2008 trainologic LTD
JavaFX



           The JavaFX Scripting Language
 • Binding and functions:

var scale = 1.0;

bound function makePoint(xPos : Number, yPos : Number) : Point {
     Point {
          x: xPos * scale
          y: yPos * scale
     }
}

var myX = 3.0;
var myY = 3.0;
def pt = bind makePoint(myX, myY);
println(pt.x); // 3

myX = 10.0;
println(pt.x); // 10

scale = 2.0;
println(pt.x); // 20



                                      19
                                                                   copyright 2008 trainologic LTD
JavaFX



         The JavaFX Scripting Language
• There is more:
      Replace Triggers
  •

      Special Access Modifiers - public-read, public-init...
  •

      Special sequences tricks.
  •

      Integration with Java classes.
  •

      Running from a Java application.
  •

      more...
  •




                               20
                                                     copyright 2008 trainologic LTD
JavaFX



• Introduction.
• The Scripting Language.
• UI - The Scene Graph.
• Deployment.




                            copyright 2008 trainologic LTD
JavaFX



                   User Interface

• JavaFX has a very strong support for building rich user
  interfaces.

• It has a very strong graphics engine which is capable of
  taking advantage of hardware graphics accelerators.

• All Swing components are supported.
• A strong API for 2D painting using the JavaFX scripting
  language.

• Support for a wide variety of media formats.


                            22
                                                 copyright 2008 trainologic LTD
JavaFX



                   User Interface

• JavaFX supports a streamlined development model
  from the designer to the developer.

• JavaFX comes with a set of plugins that enables the
  export of objects from Adobe Photoshop and Illustrator
  directly to JavaFX.




                            23
                                               copyright 2008 trainologic LTD
JavaFX



                      User Interface

• Unlike its competitors, JavaFX doesn’t use XML to
  represent the UI.

• Instead, JavaFX uses the scripting language to define a
  composite (tree like) structure of components.

• We call this structure, “The Scene Graph”.




                            24
                                                   copyright 2008 trainologic LTD
JavaFX



                     User Interface

• The main nodes in every JavaFX “tree”:
      Stage - The window hosting the application.
  •

      Scene - The canvas, where the components show.
  •

• All the components and graphic elements are put into
  the Scene.




                             25
                                                    copyright 2008 trainologic LTD
JavaFX



         User Interface




               26
                          copyright 2008 trainologic LTD
JavaFX



                              User Interface

Stage{
    title: quot;Hello Worldquot;
    width: 250
    height: 50

    scene:Scene{
        content: [
            Text{
                 content:quot;Hello Worldquot;
                 x:10
                 y:12
                 font:Font{
                      name:quot;Verdanaquot;
                      size:12
                 }
            }
        ]

    }
}




                                         27
                                               copyright 2008 trainologic LTD
JavaFX



                             User Interface

    • Adding a small piece of code can totally change the
        look.

Text{
     content:quot;Hello Worldquot;
     x:10
     y:20
     fill: Color.SEAGREEN
     font:Font{
          name:quot;Verdanaquot;
          size:20
     }
     effect: Reflection {
          fraction: 0.9
          topOpacity: 0.9
          topOffset: 0.1
     }
}




                                   28
                                                    copyright 2008 trainologic LTD
JavaFX



                             User Interface

    • Adding behavior is super easy...



Text{
     ...
     onMouseEntered: function (evt:MouseEvent) {
          evt.node.effect = Reflection {
               fraction: 0.9
               topOpacity: 0.9
               topOffset: 0.1
          }
     }
}




                                         29
                                                   copyright 2008 trainologic LTD
JavaFX



                    User Interface

• There is much more to the User Interface in JavaFX:
      Animations.
  •

      Transformations.
  •

      Layout
  •

      Media elements
  •

      More...
  •




                           30
                                               copyright 2008 trainologic LTD
JavaFX



• Introduction.
• The Scripting Language.
• UI - The Scene Graph.
• Deployment.




                            copyright 2008 trainologic LTD
JavaFX



                      Deployment

• JavaFX supports the following deployment modes:
      Standard Execution.
  •

      Web Start.
  •

      In Browser.
  •

      Mobile - Based on a MIDlet. Currently in Beta.
  •




                              32
                                                  copyright 2008 trainologic LTD
JavaFX



                           Deployment

• Standard execution is a regular process execution using
   the javafx executable.



 .../bin/javafx -classpath MyJFXApplication.jar myPackage.myMainScript.class




                                     33
                                                                copyright 2008 trainologic LTD
JavaFX



                                Deployment

    • Web Start is using the JNLP, just like a Swing Web
       Start.
<?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?>
<jnlp spec=quot;1.0+quot; codebase=quot;file:/HelloJavaFX/dist/quot; href=quot;HelloJavaFX.jnlpquot;>
    <information>
        <title>HelloJavaFX</title>
        <vendor>galmarder</vendor>
        <homepage href=quot;quot;/>
        <description>HelloJavaFX</description>
        <offline-allowed/>
        <shortcut>
            <desktop/>
        </shortcut>
    </information>
    <resources>
        <j2se version=quot;1.5+quot;/>
        <extension name=quot;JavaFX Runtimequot; href=quot;http://dl.javafx.com/javafx-rt.jnlpquot;/>
        <jar href=quot;HelloJavaFX.jarquot; main=quot;truequot;/>
    </resources>
    <application-desc main-class=quot;HelloWorldquot;/>
</jnlp>


                                          34
                                                                    copyright 2008 trainologic LTD
JavaFX



                        Deployment

• In-Browser - The good old Applet...


         <script src=quot;http://dl.javafx.com/dtfx.jsquot;></script>
         <script>
             javafx(
                  {
                       archive: quot;HelloJavaFX.jarquot;,
                       draggable: true,
                       width: 200,
                       height: 200,
                       code: quot;HelloWorldquot;,
                       name: quot;HelloJavaFXquot;
                  }
             );
         </script>




                                  35
                                                                copyright 2008 trainologic LTD
JavaFX



                     Deployment

• Mobile - There is a Mobile emulator, currently in beta.




                             36
                                                 copyright 2008 trainologic LTD
Thank You



            Q&A
             Gal Marder

             CEO, Trainologic




                  copyright 2008 trainologic LTD

Weitere ähnliche Inhalte

Andere mochten auch

What's Expected in Java 7
What's Expected in Java 7What's Expected in Java 7
What's Expected in Java 7Gal Marder
 
What's new in Java EE 6
What's new in Java EE 6What's new in Java EE 6
What's new in Java EE 6Gal Marder
 
GBDC 勉強会 #6 Java イベントレポート 2016
GBDC 勉強会 #6 Java イベントレポート 2016GBDC 勉強会 #6 Java イベントレポート 2016
GBDC 勉強会 #6 Java イベントレポート 2016Yutaka Kato
 
JavaFX - Straight from the trenches
JavaFX - Straight from the trenchesJavaFX - Straight from the trenches
JavaFX - Straight from the trenchesAnderson Braz
 
JavaFX 2.0 and Alternative Languages
JavaFX 2.0 and Alternative LanguagesJavaFX 2.0 and Alternative Languages
JavaFX 2.0 and Alternative LanguagesStephen Chin
 
JavaFX 2.1 - следующее поколение клиентской Java
JavaFX 2.1 - следующее поколение клиентской JavaJavaFX 2.1 - следующее поколение клиентской Java
JavaFX 2.1 - следующее поколение клиентской JavaAlexander_K
 
01 - JavaFX. Введение в JavaFX
01 - JavaFX. Введение в JavaFX01 - JavaFX. Введение в JavaFX
01 - JavaFX. Введение в JavaFXRoman Brovko
 
Java Fx - Return of client Java
Java Fx - Return of client JavaJava Fx - Return of client Java
Java Fx - Return of client JavaShuji Watanabe
 
DataFX 8 (JavaOne 2014)
DataFX 8 (JavaOne 2014)DataFX 8 (JavaOne 2014)
DataFX 8 (JavaOne 2014)Hendrik Ebbers
 
JavaFX Your Way: Building JavaFX Applications with Alternative Languages
JavaFX Your Way: Building JavaFX Applications with Alternative LanguagesJavaFX Your Way: Building JavaFX Applications with Alternative Languages
JavaFX Your Way: Building JavaFX Applications with Alternative LanguagesStephen Chin
 
JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)Alexander Casall
 
Presentation - Course about JavaFX
Presentation - Course about JavaFXPresentation - Course about JavaFX
Presentation - Course about JavaFXTom Mix Petreca
 
Building Java Desktop Apps with JavaFX 8 and Java EE 7
Building Java Desktop Apps with JavaFX 8 and Java EE 7Building Java Desktop Apps with JavaFX 8 and Java EE 7
Building Java Desktop Apps with JavaFX 8 and Java EE 7Bruno Borges
 

Andere mochten auch (20)

What's Expected in Java 7
What's Expected in Java 7What's Expected in Java 7
What's Expected in Java 7
 
What's new in Java EE 6
What's new in Java EE 6What's new in Java EE 6
What's new in Java EE 6
 
GBDC 勉強会 #6 Java イベントレポート 2016
GBDC 勉強会 #6 Java イベントレポート 2016GBDC 勉強会 #6 Java イベントレポート 2016
GBDC 勉強会 #6 Java イベントレポート 2016
 
JavaFX - Straight from the trenches
JavaFX - Straight from the trenchesJavaFX - Straight from the trenches
JavaFX - Straight from the trenches
 
JavaFX 2.0 and Alternative Languages
JavaFX 2.0 and Alternative LanguagesJavaFX 2.0 and Alternative Languages
JavaFX 2.0 and Alternative Languages
 
JavaFX technology
JavaFX technologyJavaFX technology
JavaFX technology
 
JavaFX 2.0 overview
JavaFX 2.0 overviewJavaFX 2.0 overview
JavaFX 2.0 overview
 
JavaFX 2.1 - следующее поколение клиентской Java
JavaFX 2.1 - следующее поколение клиентской JavaJavaFX 2.1 - следующее поколение клиентской Java
JavaFX 2.1 - следующее поколение клиентской Java
 
01 - JavaFX. Введение в JavaFX
01 - JavaFX. Введение в JavaFX01 - JavaFX. Введение в JavaFX
01 - JavaFX. Введение в JavaFX
 
JavaFX introduction
JavaFX introductionJavaFX introduction
JavaFX introduction
 
From Swing to JavaFX
From Swing to JavaFXFrom Swing to JavaFX
From Swing to JavaFX
 
Java Fx - Return of client Java
Java Fx - Return of client JavaJava Fx - Return of client Java
Java Fx - Return of client Java
 
JavaFX Advanced
JavaFX AdvancedJavaFX Advanced
JavaFX Advanced
 
Introduction to JavaFX 2
Introduction to JavaFX 2Introduction to JavaFX 2
Introduction to JavaFX 2
 
DataFX 8 (JavaOne 2014)
DataFX 8 (JavaOne 2014)DataFX 8 (JavaOne 2014)
DataFX 8 (JavaOne 2014)
 
JavaFX Your Way: Building JavaFX Applications with Alternative Languages
JavaFX Your Way: Building JavaFX Applications with Alternative LanguagesJavaFX Your Way: Building JavaFX Applications with Alternative Languages
JavaFX Your Way: Building JavaFX Applications with Alternative Languages
 
JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)
 
Presentation - Course about JavaFX
Presentation - Course about JavaFXPresentation - Course about JavaFX
Presentation - Course about JavaFX
 
Building Java Desktop Apps with JavaFX 8 and Java EE 7
Building Java Desktop Apps with JavaFX 8 and Java EE 7Building Java Desktop Apps with JavaFX 8 and Java EE 7
Building Java Desktop Apps with JavaFX 8 and Java EE 7
 
Mini-curso JavaFX Aula1
Mini-curso JavaFX Aula1Mini-curso JavaFX Aula1
Mini-curso JavaFX Aula1
 

Mehr von Gal Marder

Should i break it?
Should i break it?Should i break it?
Should i break it?Gal Marder
 
Reactive Micro Services with Java seminar
Reactive Micro Services with Java seminarReactive Micro Services with Java seminar
Reactive Micro Services with Java seminarGal Marder
 
JVM languages "flame wars"
JVM languages "flame wars"JVM languages "flame wars"
JVM languages "flame wars"Gal Marder
 
Dive into spark2
Dive into spark2Dive into spark2
Dive into spark2Gal Marder
 
Stream processing from single node to a cluster
Stream processing from single node to a clusterStream processing from single node to a cluster
Stream processing from single node to a clusterGal Marder
 
Implementing Micro Services Tasks (service discovery, load balancing etc.) - ...
Implementing Micro Services Tasks (service discovery, load balancing etc.) - ...Implementing Micro Services Tasks (service discovery, load balancing etc.) - ...
Implementing Micro Services Tasks (service discovery, load balancing etc.) - ...Gal Marder
 
Spark real world use cases and optimizations
Spark real world use cases and optimizationsSpark real world use cases and optimizations
Spark real world use cases and optimizationsGal Marder
 
What’s expected in Java 9
What’s expected in Java 9What’s expected in Java 9
What’s expected in Java 9Gal Marder
 
What’s expected in Spring 5
What’s expected in Spring 5What’s expected in Spring 5
What’s expected in Spring 5Gal Marder
 
Multi-threading in the modern era: Vertx Akka and Quasar
Multi-threading in the modern era: Vertx Akka and QuasarMulti-threading in the modern era: Vertx Akka and Quasar
Multi-threading in the modern era: Vertx Akka and QuasarGal Marder
 

Mehr von Gal Marder (10)

Should i break it?
Should i break it?Should i break it?
Should i break it?
 
Reactive Micro Services with Java seminar
Reactive Micro Services with Java seminarReactive Micro Services with Java seminar
Reactive Micro Services with Java seminar
 
JVM languages "flame wars"
JVM languages "flame wars"JVM languages "flame wars"
JVM languages "flame wars"
 
Dive into spark2
Dive into spark2Dive into spark2
Dive into spark2
 
Stream processing from single node to a cluster
Stream processing from single node to a clusterStream processing from single node to a cluster
Stream processing from single node to a cluster
 
Implementing Micro Services Tasks (service discovery, load balancing etc.) - ...
Implementing Micro Services Tasks (service discovery, load balancing etc.) - ...Implementing Micro Services Tasks (service discovery, load balancing etc.) - ...
Implementing Micro Services Tasks (service discovery, load balancing etc.) - ...
 
Spark real world use cases and optimizations
Spark real world use cases and optimizationsSpark real world use cases and optimizations
Spark real world use cases and optimizations
 
What’s expected in Java 9
What’s expected in Java 9What’s expected in Java 9
What’s expected in Java 9
 
What’s expected in Spring 5
What’s expected in Spring 5What’s expected in Spring 5
What’s expected in Spring 5
 
Multi-threading in the modern era: Vertx Akka and Quasar
Multi-threading in the modern era: Vertx Akka and QuasarMulti-threading in the modern era: Vertx Akka and Quasar
Multi-threading in the modern era: Vertx Akka and Quasar
 

Kürzlich hochgeladen

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 

Kürzlich hochgeladen (20)

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 

Introduction to Java FX

  • 1. JavaFX Rich Internet Application with Java copyright 2008 trainologic LTD
  • 2. JavaFX • Introduction. • The Scripting Language. • UI - The Scene Graph. • Deployment. copyright 2008 trainologic LTD
  • 3. JavaFX What is JavaFX? • Started from the F3 project developed by Chris Oliver. • Java’s Rich Internet Application Platform. • Direct Competition with Adobe Flash/Flex/Air. • Direct competition with MS Silverlite. 3 copyright 2008 trainologic LTD
  • 4. JavaFX What is JavaFX? A platform and tools suite that offers distinct advantages to Web developers, Web designers, and Java developers who are building rich, connected experiences. 4 copyright 2008 trainologic LTD
  • 5. JavaFX What is JavaFX? • Composed of a simple scripting language, combined with enhanced graphics abilities. • Tools that help designers and developers work closer together. • Runs on the JVM. • Deploys easily to the desktop, browser. • Future releases are planed to support Mobile Phones and TV. 5 copyright 2008 trainologic LTD
  • 6. JavaFX What is JavaFX? 6 copyright 2008 trainologic LTD
  • 7. JavaFX • Introduction. • The Scripting Language. • UI - The Scene Graph. • Deployment. copyright 2008 trainologic LTD
  • 8. JavaFX The JavaFX Scripting Language • As the name suggests, it is a scripting language. • Unlike many other scripting languages, it is a compiled language. • As you probably guessed, it is compiling to Java Classes. • Unlike Java, it has a handful of tricks that makes the development really easy... We will cover some of them. 8 copyright 2008 trainologic LTD
  • 9. JavaFX The JavaFX Scripting Language • Let’s dive into the water... result = add(1, 2); println(quot;1 + 2 = {result}quot;); function add(numOne:Integer, numTwo:Integer):Integer { var result = numOne + numTwo; return result; } 9 copyright 2008 trainologic LTD
  • 10. JavaFX The JavaFX Scripting Language • So... What do we have here? • Code out of a class. • Untyped variables. • Special String literal. • There is much more... 10 copyright 2008 trainologic LTD
  • 11. JavaFX The JavaFX Scripting Language • Declaring a class: class Customer { var firstName: String; var lastName: String; var phoneNum: String; var address: Address; function printName() { println(quot;Name: {firstName} {lastName}quot;); } 11 copyright 2008 trainologic LTD
  • 12. JavaFX The JavaFX Scripting Language • Object literals: def customer = Customer { firstName: quot;Johnquot;; lastName: quot;Doequot;; phoneNum: quot;(408) 555-1212quot;; address: Address { street: quot;1 Main Streetquot;; city: quot;Santa Claraquot;; state: quot;CAquot;; zip: quot;95050quot;; } } 12 copyright 2008 trainologic LTD
  • 13. JavaFX The JavaFX Scripting Language • The basic data types: String - “Hello”, ‘Hello’, “Hello {expression}” • Number - 4.2 • Integer - 3 • Boolean - true, false • Duration - 10ms, 5s, 3m, 1h • Void - just like Java, but written with upper-case. • null - just the same as in Java. • 13 copyright 2008 trainologic LTD
  • 14. JavaFX The JavaFX Scripting Language • Sequences: // Sequence Literal var weekDays: String[] = [quot;Monquot;,quot;Tuequot;,quot;Wedquot;,quot;Thuquot;,quot;Friquot;]; // Sequence Concatenation var days = [weekDays, [quot;Satquot;,quot;Sunquot;]]; // Sequence ranges var nums = [1..100] var nums = [1..100 step 2] // 1, 3, 5, ...99 // Sequence Querying var numsGreaterThanTwo = nums[n | n > 2]; // 3, 4, 5 ...100 14 copyright 2008 trainologic LTD
  • 15. JavaFX The JavaFX Scripting Language • Block Expression - Returns the value of the last expression in the block. var nums = [5, 7, 3, 9]; var total = { var sum = 0; for (a in nums) { sum += a }; sum; } println(quot;Total is {total}.quot;); 15 copyright 2008 trainologic LTD
  • 16. JavaFX The JavaFX Scripting Language • Another cool feature in JavaFX is data binding. • Data binding means binding the value of one variable to another. • When the first changes it changes the second as well. • Objects and methods can also be bound. • Let’s take a look... 16 copyright 2008 trainologic LTD
  • 17. JavaFX The JavaFX Scripting Language • Binding two variables, not so impressive... var x = 0; def y = bind x; x = 1; println(y); // y now equals 1 x = 47; println(y); // y now equals 47 17 copyright 2008 trainologic LTD
  • 18. JavaFX The JavaFX Scripting Language • Binding an object, starting to get more interesting... var myStreet = quot;1 Main Streetquot;; var myCity = quot;Santa Claraquot;; var myState = quot;CAquot;; var myZip = quot;95050quot;; def address = bind Address { street: myStreet; city: myCity; state: myState; zip: myZip; }; println(quot;address.street == {address.street}quot;); // 1 Main Street myStreet = quot;100 Maple Streetquot;; println(quot;address.street == {address.street}quot;); // 100 Maple Street 18 copyright 2008 trainologic LTD
  • 19. JavaFX The JavaFX Scripting Language • Binding and functions: var scale = 1.0; bound function makePoint(xPos : Number, yPos : Number) : Point { Point { x: xPos * scale y: yPos * scale } } var myX = 3.0; var myY = 3.0; def pt = bind makePoint(myX, myY); println(pt.x); // 3 myX = 10.0; println(pt.x); // 10 scale = 2.0; println(pt.x); // 20 19 copyright 2008 trainologic LTD
  • 20. JavaFX The JavaFX Scripting Language • There is more: Replace Triggers • Special Access Modifiers - public-read, public-init... • Special sequences tricks. • Integration with Java classes. • Running from a Java application. • more... • 20 copyright 2008 trainologic LTD
  • 21. JavaFX • Introduction. • The Scripting Language. • UI - The Scene Graph. • Deployment. copyright 2008 trainologic LTD
  • 22. JavaFX User Interface • JavaFX has a very strong support for building rich user interfaces. • It has a very strong graphics engine which is capable of taking advantage of hardware graphics accelerators. • All Swing components are supported. • A strong API for 2D painting using the JavaFX scripting language. • Support for a wide variety of media formats. 22 copyright 2008 trainologic LTD
  • 23. JavaFX User Interface • JavaFX supports a streamlined development model from the designer to the developer. • JavaFX comes with a set of plugins that enables the export of objects from Adobe Photoshop and Illustrator directly to JavaFX. 23 copyright 2008 trainologic LTD
  • 24. JavaFX User Interface • Unlike its competitors, JavaFX doesn’t use XML to represent the UI. • Instead, JavaFX uses the scripting language to define a composite (tree like) structure of components. • We call this structure, “The Scene Graph”. 24 copyright 2008 trainologic LTD
  • 25. JavaFX User Interface • The main nodes in every JavaFX “tree”: Stage - The window hosting the application. • Scene - The canvas, where the components show. • • All the components and graphic elements are put into the Scene. 25 copyright 2008 trainologic LTD
  • 26. JavaFX User Interface 26 copyright 2008 trainologic LTD
  • 27. JavaFX User Interface Stage{ title: quot;Hello Worldquot; width: 250 height: 50 scene:Scene{ content: [ Text{ content:quot;Hello Worldquot; x:10 y:12 font:Font{ name:quot;Verdanaquot; size:12 } } ] } } 27 copyright 2008 trainologic LTD
  • 28. JavaFX User Interface • Adding a small piece of code can totally change the look. Text{ content:quot;Hello Worldquot; x:10 y:20 fill: Color.SEAGREEN font:Font{ name:quot;Verdanaquot; size:20 } effect: Reflection { fraction: 0.9 topOpacity: 0.9 topOffset: 0.1 } } 28 copyright 2008 trainologic LTD
  • 29. JavaFX User Interface • Adding behavior is super easy... Text{ ... onMouseEntered: function (evt:MouseEvent) { evt.node.effect = Reflection { fraction: 0.9 topOpacity: 0.9 topOffset: 0.1 } } } 29 copyright 2008 trainologic LTD
  • 30. JavaFX User Interface • There is much more to the User Interface in JavaFX: Animations. • Transformations. • Layout • Media elements • More... • 30 copyright 2008 trainologic LTD
  • 31. JavaFX • Introduction. • The Scripting Language. • UI - The Scene Graph. • Deployment. copyright 2008 trainologic LTD
  • 32. JavaFX Deployment • JavaFX supports the following deployment modes: Standard Execution. • Web Start. • In Browser. • Mobile - Based on a MIDlet. Currently in Beta. • 32 copyright 2008 trainologic LTD
  • 33. JavaFX Deployment • Standard execution is a regular process execution using the javafx executable. .../bin/javafx -classpath MyJFXApplication.jar myPackage.myMainScript.class 33 copyright 2008 trainologic LTD
  • 34. JavaFX Deployment • Web Start is using the JNLP, just like a Swing Web Start. <?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?> <jnlp spec=quot;1.0+quot; codebase=quot;file:/HelloJavaFX/dist/quot; href=quot;HelloJavaFX.jnlpquot;> <information> <title>HelloJavaFX</title> <vendor>galmarder</vendor> <homepage href=quot;quot;/> <description>HelloJavaFX</description> <offline-allowed/> <shortcut> <desktop/> </shortcut> </information> <resources> <j2se version=quot;1.5+quot;/> <extension name=quot;JavaFX Runtimequot; href=quot;http://dl.javafx.com/javafx-rt.jnlpquot;/> <jar href=quot;HelloJavaFX.jarquot; main=quot;truequot;/> </resources> <application-desc main-class=quot;HelloWorldquot;/> </jnlp> 34 copyright 2008 trainologic LTD
  • 35. JavaFX Deployment • In-Browser - The good old Applet... <script src=quot;http://dl.javafx.com/dtfx.jsquot;></script> <script> javafx( { archive: quot;HelloJavaFX.jarquot;, draggable: true, width: 200, height: 200, code: quot;HelloWorldquot;, name: quot;HelloJavaFXquot; } ); </script> 35 copyright 2008 trainologic LTD
  • 36. JavaFX Deployment • Mobile - There is a Mobile emulator, currently in beta. 36 copyright 2008 trainologic LTD
  • 37. Thank You Q&A Gal Marder CEO, Trainologic copyright 2008 trainologic LTD