SlideShare a Scribd company logo
1 of 31
Download to read offline
Rich Internet Applications
 con JavaFX e NetBeans
            A cura di:

        Fabrizio Giudici
Introduction

• JavaFX, an “umbrella” for RIA
  –   JavaFX Script
  –   Desktop runtime
  –   JavaFX Mobile
  –   More to come (design tools?)
• NetBeans, an IDE
  – Java and other languages
Context

• Will compete with
  – Adobe's Flash/Flex/Air
  – Microsoft Silverlight
• Based on the Java Virtual Machine
• Upcoming “Consumer JRE”
  – See “Java 6 Update N”
It's what you're thinking...




It is intended to make Applets!
         (among others)
Samples
JavaFX Script

•   Object oriented
•   Declarative
•   Statically typed
•   Can access the whole Java Runtime
    – Comes with runtime extensions
• Currently interpreted
    – Compiler coming soon
An example

import javafx.ui.*;

     Frame {
            title: "Hello World JavaFX"
            width: 200
            height: 50
            content: Label {
                text: "Hello World"
            }
            visible: true
     }
Procedural fashion too

var win = new Frame();
win.title = "Hello World JavaFX";
win.width = 200;
var label = new Label();
label.text = "Hello World";
win.content = label;
win.visible = true;
Model / View / Controller

• MVC is a foundation, of course
• JavaFX allows to minimize the
  boilerplate code between M and VC
• Binding
  – Incremental
  – Bidirectional
Binding

class HelloWorldModel {
    attribute saying: String;
}
var model = HelloWorldModel {
    saying: "Hello World"
};
Frame {
    title: "Hello World JavaFX"
    width: 200
    content: Label {
        text: bind model.saying
    }
    visible: true
};
Basic components (widgets)

•   Border          •   ListBox
•   LayoutManager   •   RadioButton...
•   Menu            •   ComboBox
•   Label           •   Tree, Table
•   GroupPanel      •   TextComponents
•   Button          •   Spinner, Slider
Changes from plain Swing

• LayoutManager → LayoutPanel
• GroupPanel is supported
• StackPanel
Listeners

• Similar concept, different
  implementation than Swing
  – operations (methods) can be defined on
    the fly
  – no inner classes
A Listener example


Button {
    text: "I'm a button!"
    mnemonic: I
    action: operation() {
        model.numClicks++;
  }
Labels

• Can contain HTML
• HTML can contain dynamic parts
Dynamic HTML example
content: Label {
      text: bind
        "<html>
             <h2 align='center'>Shopping Cart</h2>
             <table align='center' ...>
                <tr bgcolor='#cccccc'>
                   <td><b>Item ID</b></td>
                   <td><b>Available</b></td>
                   <td><b>List Price</b></td>
                   <td> </td>
                 </tr>

                {
                    if (sizeof cart.items == 0)
                    then "<tr><td'><b>Your cart is empty.</b></td></tr>"
                    else foreach (item in cart.items)
                        "<tr><td>{if item.inStock then "Yes" else "No"}</td>
                         <td align='right'>{item.totalCost}</td></tr>"
                }
              </table>
           </html>"
     }
Too many words! Let's go coding!
The application
Steps

•   Get introduced to NetBeans
•   Create model classes
•   Create and bind some UI element
•   Events
•   Advanced stuff (search)
•   Integration with other tiers
Model classes

• Person, Email, PhoneNumber
• PersonFactory
• PersonListModel
Triggers
trigger on new PersonListModel
  {
    personFactory.load();
    detailPane.person = personFactory.all[0];
  }

trigger on PersonListModel.selectedPerson = newValue
  {
    detailPane.person = personFactory.all[newValue];
  }
Arrays
var x = [1,2,3];
        insert 12 into x; // yields [1,2,3,12]
        insert 10 as first into x; // yields [10,1,2,3,12]
        insert [99,100] as last into x; // yields [10,1,2,3,12,99,100]

var x = [1,2,3];
        insert 10 after x[. == 10]; // yields [1,2,3,10]
        insert 12 before x[1]; // yields [1,12,2,3,10]
        insert 13 after x[. == 2]; // yields [1, 12, 2, 13, 3, 10];

var x = [1,2,3];
        insert 10 into x; // yields [1,2,3,10]
        insert 12 before x[1]; // yields [1,12,2,3,10]
        delete x[. == 12]; // yields [1,2,3,10]
        delete x[. >= 3]; // yields [1,2]
        insert 5 after x[. == 1]; // yields [1,5,2];
        insert 13 as first into x; // yields [13, 1, 5, 2];
        delete x; // yields []
ListBox

• Model
• Selected object(s)
• Cell configuration
Canvas, Group

• Canvas allows to mix components
  with graphics
• Group is the glue between Canvas
  and complex structures
ListBox example


ListBox
  {
    layoutOrientation: VERTICAL
    selection: bind personListModel.selectedPerson
    cells: bind foreach
      (person in personListModel.personFactory.all)
    ListCell
      {
        text: "{person.firstName} {person.secondName}"
      }
  }
Search (array query)

• “List comprehensions”
  – Create a list out of another list
  – With criteria (e.g. filtering)
  –
• select n*n from n in [1..100]
Search (array query)

select indexof track + 1
  from album in albums,
       track in album.tracks
  where track == album.title;


function factors(n)
  {
    return select i from i in [1..n/2]
              where n % i == 0;
  }
In our case

TextField
  {
     value: "Search"
     onChange: operation (string: String)
     {
        personListModel.selectedPerson =
          (select indexof person
           from person in
                personListModel.personFactory.all
           where person.secondName == string)[0];
     }
  }
Talking to other tiers

• JavaFX uses the Java Runtime...
• ... you can use whatever you need
  – RMI, Spring Remoting, SOAP, Corba...
• Only pay attention to the footprint
  – What will be in the “Customer JRE”?
JFXBuilder

     • See a few
       samples
Question Time

• ... and feedback too



 What do you think about JavaFX?

More Related Content

What's hot

D2W Stateful Controllers
D2W Stateful ControllersD2W Stateful Controllers
D2W Stateful Controllers
WO Community
 

What's hot (20)

Drupal 8 Hooks
Drupal 8 HooksDrupal 8 Hooks
Drupal 8 Hooks
 
Basic java for Android Developer
Basic java for Android DeveloperBasic java for Android Developer
Basic java for Android Developer
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller Columns
 
JavaScript
JavaScriptJavaScript
JavaScript
 
PHP- Introduction to Object Oriented PHP
PHP-  Introduction to Object Oriented PHPPHP-  Introduction to Object Oriented PHP
PHP- Introduction to Object Oriented PHP
 
OOP in PHP
OOP in PHPOOP in PHP
OOP in PHP
 
Introduction to jOOQ
Introduction to jOOQIntroduction to jOOQ
Introduction to jOOQ
 
Introduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examplesIntroduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examples
 
ERRest - The Next Steps
ERRest - The Next StepsERRest - The Next Steps
ERRest - The Next Steps
 
Java Swing
Java SwingJava Swing
Java Swing
 
Java for beginners
Java for beginnersJava for beginners
Java for beginners
 
Object Oriented PHP5
Object Oriented PHP5Object Oriented PHP5
Object Oriented PHP5
 
A Dexterity Intro for Recovering Archetypes Addicts
A Dexterity Intro for Recovering Archetypes AddictsA Dexterity Intro for Recovering Archetypes Addicts
A Dexterity Intro for Recovering Archetypes Addicts
 
JSP Standard Tag Library
JSP Standard Tag LibraryJSP Standard Tag Library
JSP Standard Tag Library
 
2. overview of c#
2. overview of c#2. overview of c#
2. overview of c#
 
D2W Stateful Controllers
D2W Stateful ControllersD2W Stateful Controllers
D2W Stateful Controllers
 
JPA and Hibernate
JPA and HibernateJPA and Hibernate
JPA and Hibernate
 
JavaScript, VBScript, AJAX, CGI
JavaScript, VBScript, AJAX, CGIJavaScript, VBScript, AJAX, CGI
JavaScript, VBScript, AJAX, CGI
 
PHP - Introduction to Object Oriented Programming with PHP
PHP -  Introduction to  Object Oriented Programming with PHPPHP -  Introduction to  Object Oriented Programming with PHP
PHP - Introduction to Object Oriented Programming with PHP
 

Viewers also liked (7)

Accession Intl Capabilities Statement - 2011
Accession Intl Capabilities Statement - 2011Accession Intl Capabilities Statement - 2011
Accession Intl Capabilities Statement - 2011
 
Voice of Mogolia-0.2
Voice of Mogolia-0.2Voice of Mogolia-0.2
Voice of Mogolia-0.2
 
Building software using Rich Clients Platforms Rikard Thulin
Building software using Rich Clients Platforms Rikard ThulinBuilding software using Rich Clients Platforms Rikard Thulin
Building software using Rich Clients Platforms Rikard Thulin
 
Netbeans65 Osum Slides
Netbeans65 Osum SlidesNetbeans65 Osum Slides
Netbeans65 Osum Slides
 
Java桌面应用开发
Java桌面应用开发Java桌面应用开发
Java桌面应用开发
 
NetBeans Platform for Rich Client Development
NetBeans Platform for Rich Client DevelopmentNetBeans Platform for Rich Client Development
NetBeans Platform for Rich Client Development
 
java swing programming
java swing programming java swing programming
java swing programming
 

Similar to Rich Internet Applications con JavaFX e NetBeans

Overview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web FrameworkOverview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web Framework
IndicThreads
 
Scala based Lift Framework
Scala based Lift FrameworkScala based Lift Framework
Scala based Lift Framework
vhazrati
 
fuser interface-development-using-jquery
fuser interface-development-using-jqueryfuser interface-development-using-jquery
fuser interface-development-using-jquery
Kostas Mavridis
 

Similar to Rich Internet Applications con JavaFX e NetBeans (20)

Jquery fundamentals
Jquery fundamentalsJquery fundamentals
Jquery fundamentals
 
Spring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard WolffSpring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard Wolff
 
Html5 and web technology update
Html5 and web technology updateHtml5 and web technology update
Html5 and web technology update
 
Building DSLs with Groovy
Building DSLs with GroovyBuilding DSLs with Groovy
Building DSLs with Groovy
 
JavaScript!
JavaScript!JavaScript!
JavaScript!
 
The Inclusive Web: hands-on with HTML5 and jQuery
The Inclusive Web: hands-on with HTML5 and jQueryThe Inclusive Web: hands-on with HTML5 and jQuery
The Inclusive Web: hands-on with HTML5 and jQuery
 
Local storage in Web apps
Local storage in Web appsLocal storage in Web apps
Local storage in Web apps
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 
Week3
Week3Week3
Week3
 
JavaScript for Flex Devs
JavaScript for Flex DevsJavaScript for Flex Devs
JavaScript for Flex Devs
 
JavaScript Workshop
JavaScript WorkshopJavaScript Workshop
JavaScript Workshop
 
Overview Of Lift Framework
Overview Of Lift FrameworkOverview Of Lift Framework
Overview Of Lift Framework
 
Overview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web FrameworkOverview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web Framework
 
Scala based Lift Framework
Scala based Lift FrameworkScala based Lift Framework
Scala based Lift Framework
 
Local Storage
Local StorageLocal Storage
Local Storage
 
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSONAn introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
 
fuser interface-development-using-jquery
fuser interface-development-using-jqueryfuser interface-development-using-jquery
fuser interface-development-using-jquery
 
Scala and Spring
Scala and SpringScala and Spring
Scala and Spring
 
Local data storage for mobile apps
Local data storage for mobile appsLocal data storage for mobile apps
Local data storage for mobile apps
 
Couchbas for dummies
Couchbas for dummiesCouchbas for dummies
Couchbas for dummies
 

More from Fabrizio Giudici

NOSQL also means RDF stores: an Android case study
NOSQL also means RDF stores: an Android case studyNOSQL also means RDF stores: an Android case study
NOSQL also means RDF stores: an Android case study
Fabrizio Giudici
 
Tools for an effective software factory
Tools for an effective software factoryTools for an effective software factory
Tools for an effective software factory
Fabrizio Giudici
 
Parallel Computing Scenarios and the new challenges for the Software Architect
Parallel Computing Scenarios  and the new challenges for the Software ArchitectParallel Computing Scenarios  and the new challenges for the Software Architect
Parallel Computing Scenarios and the new challenges for the Software Architect
Fabrizio Giudici
 
blueMarine a desktop app for the open source photographic workflow
blueMarine  a desktop app for the open source photographic workflowblueMarine  a desktop app for the open source photographic workflow
blueMarine a desktop app for the open source photographic workflow
Fabrizio Giudici
 
blueMarine photographic workflow with Java
blueMarine photographic workflow with JavablueMarine photographic workflow with Java
blueMarine photographic workflow with Java
Fabrizio Giudici
 
blueMarine Sailing with NetBeans Platform
blueMarine Sailing with NetBeans PlatformblueMarine Sailing with NetBeans Platform
blueMarine Sailing with NetBeans Platform
Fabrizio Giudici
 
NASA World Wind for Java API Overview
NASA World Wind for Java  API OverviewNASA World Wind for Java  API Overview
NASA World Wind for Java API Overview
Fabrizio Giudici
 
Web Development with Apache Struts 2
Web Development with  Apache Struts 2Web Development with  Apache Struts 2
Web Development with Apache Struts 2
Fabrizio Giudici
 
blueMarine Or Why You Should Really Ship Swing Applications
blueMarine  Or Why You Should Really Ship Swing  Applications blueMarine  Or Why You Should Really Ship Swing  Applications
blueMarine Or Why You Should Really Ship Swing Applications
Fabrizio Giudici
 

More from Fabrizio Giudici (16)

Building Android apps with Maven
Building Android apps with MavenBuilding Android apps with Maven
Building Android apps with Maven
 
DCI - Data, Context and Interaction @ Jug Lugano May 2011
DCI - Data, Context and Interaction @ Jug Lugano May 2011 DCI - Data, Context and Interaction @ Jug Lugano May 2011
DCI - Data, Context and Interaction @ Jug Lugano May 2011
 
DCI - Data, Context and Interaction @ Jug Genova April 2011
DCI - Data, Context and Interaction @ Jug Genova April 2011DCI - Data, Context and Interaction @ Jug Genova April 2011
DCI - Data, Context and Interaction @ Jug Genova April 2011
 
NOSQL also means RDF stores: an Android case study
NOSQL also means RDF stores: an Android case studyNOSQL also means RDF stores: an Android case study
NOSQL also means RDF stores: an Android case study
 
Netbeans+platform+maven
Netbeans+platform+mavenNetbeans+platform+maven
Netbeans+platform+maven
 
Tools for an effective software factory
Tools for an effective software factoryTools for an effective software factory
Tools for an effective software factory
 
Parallel Computing Scenarios and the new challenges for the Software Architect
Parallel Computing Scenarios  and the new challenges for the Software ArchitectParallel Computing Scenarios  and the new challenges for the Software Architect
Parallel Computing Scenarios and the new challenges for the Software Architect
 
blueMarine a desktop app for the open source photographic workflow
blueMarine  a desktop app for the open source photographic workflowblueMarine  a desktop app for the open source photographic workflow
blueMarine a desktop app for the open source photographic workflow
 
blueMarine photographic workflow with Java
blueMarine photographic workflow with JavablueMarine photographic workflow with Java
blueMarine photographic workflow with Java
 
blueMarine Sailing with NetBeans Platform
blueMarine Sailing with NetBeans PlatformblueMarine Sailing with NetBeans Platform
blueMarine Sailing with NetBeans Platform
 
NASA World Wind for Java API Overview
NASA World Wind for Java  API OverviewNASA World Wind for Java  API Overview
NASA World Wind for Java API Overview
 
The VRC Project
The VRC ProjectThe VRC Project
The VRC Project
 
Web Development with Apache Struts 2
Web Development with  Apache Struts 2Web Development with  Apache Struts 2
Web Development with Apache Struts 2
 
blueMarine Or Why You Should Really Ship Swing Applications
blueMarine  Or Why You Should Really Ship Swing  Applications blueMarine  Or Why You Should Really Ship Swing  Applications
blueMarine Or Why You Should Really Ship Swing Applications
 
Android java fx-jme@jug-lugano
Android java fx-jme@jug-luganoAndroid java fx-jme@jug-lugano
Android java fx-jme@jug-lugano
 
Mercurial
MercurialMercurial
Mercurial
 

Recently uploaded

Recently uploaded (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Rich Internet Applications con JavaFX e NetBeans

  • 1. Rich Internet Applications con JavaFX e NetBeans A cura di: Fabrizio Giudici
  • 2. Introduction • JavaFX, an “umbrella” for RIA – JavaFX Script – Desktop runtime – JavaFX Mobile – More to come (design tools?) • NetBeans, an IDE – Java and other languages
  • 3. Context • Will compete with – Adobe's Flash/Flex/Air – Microsoft Silverlight • Based on the Java Virtual Machine • Upcoming “Consumer JRE” – See “Java 6 Update N”
  • 4. It's what you're thinking... It is intended to make Applets! (among others)
  • 6. JavaFX Script • Object oriented • Declarative • Statically typed • Can access the whole Java Runtime – Comes with runtime extensions • Currently interpreted – Compiler coming soon
  • 7. An example import javafx.ui.*; Frame { title: "Hello World JavaFX" width: 200 height: 50 content: Label { text: "Hello World" } visible: true }
  • 8. Procedural fashion too var win = new Frame(); win.title = "Hello World JavaFX"; win.width = 200; var label = new Label(); label.text = "Hello World"; win.content = label; win.visible = true;
  • 9. Model / View / Controller • MVC is a foundation, of course • JavaFX allows to minimize the boilerplate code between M and VC • Binding – Incremental – Bidirectional
  • 10. Binding class HelloWorldModel { attribute saying: String; } var model = HelloWorldModel { saying: "Hello World" }; Frame { title: "Hello World JavaFX" width: 200 content: Label { text: bind model.saying } visible: true };
  • 11. Basic components (widgets) • Border • ListBox • LayoutManager • RadioButton... • Menu • ComboBox • Label • Tree, Table • GroupPanel • TextComponents • Button • Spinner, Slider
  • 12. Changes from plain Swing • LayoutManager → LayoutPanel • GroupPanel is supported • StackPanel
  • 13. Listeners • Similar concept, different implementation than Swing – operations (methods) can be defined on the fly – no inner classes
  • 14. A Listener example Button { text: "I'm a button!" mnemonic: I action: operation() { model.numClicks++; }
  • 15. Labels • Can contain HTML • HTML can contain dynamic parts
  • 16. Dynamic HTML example content: Label { text: bind "<html> <h2 align='center'>Shopping Cart</h2> <table align='center' ...> <tr bgcolor='#cccccc'> <td><b>Item ID</b></td> <td><b>Available</b></td> <td><b>List Price</b></td> <td> </td> </tr> { if (sizeof cart.items == 0) then "<tr><td'><b>Your cart is empty.</b></td></tr>" else foreach (item in cart.items) "<tr><td>{if item.inStock then "Yes" else "No"}</td> <td align='right'>{item.totalCost}</td></tr>" } </table> </html>" }
  • 17. Too many words! Let's go coding!
  • 19. Steps • Get introduced to NetBeans • Create model classes • Create and bind some UI element • Events • Advanced stuff (search) • Integration with other tiers
  • 20. Model classes • Person, Email, PhoneNumber • PersonFactory • PersonListModel
  • 21. Triggers trigger on new PersonListModel { personFactory.load(); detailPane.person = personFactory.all[0]; } trigger on PersonListModel.selectedPerson = newValue { detailPane.person = personFactory.all[newValue]; }
  • 22. Arrays var x = [1,2,3]; insert 12 into x; // yields [1,2,3,12] insert 10 as first into x; // yields [10,1,2,3,12] insert [99,100] as last into x; // yields [10,1,2,3,12,99,100] var x = [1,2,3]; insert 10 after x[. == 10]; // yields [1,2,3,10] insert 12 before x[1]; // yields [1,12,2,3,10] insert 13 after x[. == 2]; // yields [1, 12, 2, 13, 3, 10]; var x = [1,2,3]; insert 10 into x; // yields [1,2,3,10] insert 12 before x[1]; // yields [1,12,2,3,10] delete x[. == 12]; // yields [1,2,3,10] delete x[. >= 3]; // yields [1,2] insert 5 after x[. == 1]; // yields [1,5,2]; insert 13 as first into x; // yields [13, 1, 5, 2]; delete x; // yields []
  • 23. ListBox • Model • Selected object(s) • Cell configuration
  • 24. Canvas, Group • Canvas allows to mix components with graphics • Group is the glue between Canvas and complex structures
  • 25. ListBox example ListBox { layoutOrientation: VERTICAL selection: bind personListModel.selectedPerson cells: bind foreach (person in personListModel.personFactory.all) ListCell { text: "{person.firstName} {person.secondName}" } }
  • 26. Search (array query) • “List comprehensions” – Create a list out of another list – With criteria (e.g. filtering) – • select n*n from n in [1..100]
  • 27. Search (array query) select indexof track + 1 from album in albums, track in album.tracks where track == album.title; function factors(n) { return select i from i in [1..n/2] where n % i == 0; }
  • 28. In our case TextField { value: "Search" onChange: operation (string: String) { personListModel.selectedPerson = (select indexof person from person in personListModel.personFactory.all where person.secondName == string)[0]; } }
  • 29. Talking to other tiers • JavaFX uses the Java Runtime... • ... you can use whatever you need – RMI, Spring Remoting, SOAP, Corba... • Only pay attention to the footprint – What will be in the “Customer JRE”?
  • 30. JFXBuilder • See a few samples
  • 31. Question Time • ... and feedback too What do you think about JavaFX?