SlideShare a Scribd company logo
1 of 20
Download to read offline
JavaFX programming

Tecniche di Programmazione – A.A. 2012/2013
Summary
1.   Model-View-Controller
2.   The Controller in FXML
3.   Charts




 2                        Tecniche di programmazione   A.A. 2012/2013
Model-View-Controller

        JavaFX programming
Application complexity and MVC
       Interactive, graphical applications exhibit complex
        interaction patterns
       Flow of control is in the hand of the user
       Actions are mainly asynchronous

       How to organize the program?
       Where to store data?
       How to decouple application logic from interface details?
       How to keep in sync the inner data with the visibile
        interface?

    4                             Tecniche di programmazione   A.A. 2012/2013
Media Player example




5                Tecniche di programmazione   A.A. 2012/2013
MVC pattern defined




6                Tecniche di programmazione   A.A. 2012/2013
Normal life-cycle of interaction




7                  Tecniche di programmazione   A.A. 2012/2013
Mapping concepts to JavaFX
       View: presenting the UI
           FXML
           The Nodes in the Scene Graph
       Controller: reacting to user actions
           Set of event handlers
       Model: handling the data
           Class(es) including data
           Persistent data in Data Bases




    8                                 Tecniche di programmazione   A.A. 2012/2013
Design Exercise
       Imagine an application managing a list of items (e.g.,
        names)
       Different items in the user interface should manage the
        same set of data, with different criteria and actions

       Where do you declare the data class?
       Which class should have access to which?
       Who creates what objects?




    9                            Tecniche di programmazione   A.A. 2012/2013
A possible
solution




10           Tecniche di programmazione   A.A. 2012/2013
The Controller in FXML

         JavaFX programming
The Controller in FXML
    Several attributes in FXML help in the definition of the
     Controller behavior associated to a scene
        Identification of the Controller class
        Injection of Node identifiers (references)
        Registration of event handlers
    Additionally, the JavaFX Scene Builder may generate a
     «controller skeleton» for inclusion in the project




    12                              Tecniche di programmazione   A.A. 2012/2013
Defining the Controller class
    The Root element of the scene
     graph may specify a fx:
     controller attribute
        <BorderPane
         id="BorderPane"
         xmlns:fx="http://javafx.com
         /fxml"
         fx:controller="it.polito.te
         cnprogr.RuzzleController">




    13                      Tecniche di programmazione   A.A. 2012/2013
fx:controller attribute
    Associate a "controller" class with an FXML document
        Automatically create the instance when FXML is loaded
    Should include event handler methods
    May include an initialize() method
        public void initialize();
        called once when the contents of its associated document have
         been completely loaded
        any necessary post-processing on the content




    14                            Tecniche di programmazione   A.A. 2012/2013
Accessing the controller instance
    The Application often needs to communicate with the
     controller object
        E.g., to call setModel()
    FXMLLoader provides this information

         URL location = getClass().getResource("example.fxml");

         FXMLLoader fxmlLoader = new FXMLLoader(location);

         Pane root = (Pane)fxmlLoader.load();

         MyController controller =
         (MyController)fxmlLoader.getController();



    15                              Tecniche di programmazione   A.A. 2012/2013
Injection of Node references
    The controller code may directly access various Nodes in
     the associated scene graph
    The attribute @FXML associates a Node variable with
     the corresponding node, with the same fx:id value as the
     variable name
        No more error-prone «lookup» calls...
        Local variables in the controller instance
    Try:View | Show Sample Controller Skeleton on the
     Scene Builder!
                   @FXML // fx:id="theTitle"
                      private Label theTitle;

    16                              Tecniche di programmazione   A.A. 2012/2013
Registration of Event Handlers
     In FXML, you may set a event handler
      through attributes
         onAction, onKeyTyped, onMouseClicked,
          ... hundreds more ...
     The value should be the #name of a
      method in the controller class
         With the right signature for the event
          type

<Button fx:id="cercaBtn"                       @FXML
onAction="#doCercaParola"                      void doCercaParola (
text="Cerca" />                                ActionEvent event ) {
     17                             Tecniche di programmazione   A.A. 2012/2013
Resources

JavaFX programming
Resources
    API
        http://docs.oracle.com/javafx/2/api/index.html
    FXML Controller
        http://docs.oracle.com/javafx/2/api/javafx/fxml/doc-
         files/introduction_to_fxml.html#controllers
    Books
        Head First Design Patterns, chapter 12




    21                              Tecniche di programmazione   A.A. 2012/2013
Licenza d’uso
    Queste diapositive sono distribuite con licenza Creative Commons
     “Attribuzione - Non commerciale - Condividi allo stesso modo (CC
     BY-NC-SA)”
    Sei libero:
        di riprodurre, distribuire, comunicare al pubblico, esporre in pubblico,
         rappresentare, eseguire e recitare quest'opera
        di modificare quest'opera
    Alle seguenti condizioni:
        Attribuzione — Devi attribuire la paternità dell'opera agli autori
         originali e in modo tale da non suggerire che essi avallino te o il modo in
         cui tu usi l'opera.
        Non commerciale — Non puoi usare quest'opera per fini
         commerciali.
        Condividi allo stesso modo — Se alteri o trasformi quest'opera, o se
         la usi per crearne un'altra, puoi distribuire l'opera risultante solo con una
         licenza identica o equivalente a questa.
    http://creativecommons.org/licenses/by-nc-sa/3.0/
    22                                   Tecniche di programmazione   A.A. 2012/2013

More Related Content

Viewers also liked

Strumenti e metodi per la preparazione dei contenuti in e-learning
 Strumenti e metodi per la preparazione dei contenuti in e-learning Strumenti e metodi per la preparazione dei contenuti in e-learning
Strumenti e metodi per la preparazione dei contenuti in e-learningFulvio Corno
 
Introduction to Semantic Web, Metadata, Knowledge Representation, Ontologies
Introduction to Semantic Web, Metadata, Knowledge Representation, OntologiesIntroduction to Semantic Web, Metadata, Knowledge Representation, Ontologies
Introduction to Semantic Web, Metadata, Knowledge Representation, OntologiesFulvio Corno
 
Web Architecture and Technologies
Web Architecture and TechnologiesWeb Architecture and Technologies
Web Architecture and TechnologiesFulvio Corno
 
Ambient Intelligence - Course Introduction
Ambient Intelligence - Course IntroductionAmbient Intelligence - Course Introduction
Ambient Intelligence - Course IntroductionFulvio Corno
 
Introduction to JSP pages
Introduction to JSP pagesIntroduction to JSP pages
Introduction to JSP pagesFulvio Corno
 
Presentazione Laurea Magistrale in Ingegneria Informatica del Politecnico di ...
Presentazione Laurea Magistrale in Ingegneria Informatica del Politecnico di ...Presentazione Laurea Magistrale in Ingegneria Informatica del Politecnico di ...
Presentazione Laurea Magistrale in Ingegneria Informatica del Politecnico di ...Fulvio Corno
 
E-learning e teorie sull'apprendimento
 E-learning e teorie sull'apprendimento E-learning e teorie sull'apprendimento
E-learning e teorie sull'apprendimentoFulvio Corno
 
Gli anelli mancanti per l’Ambient Intelligence
Gli anelli mancanti per l’Ambient IntelligenceGli anelli mancanti per l’Ambient Intelligence
Gli anelli mancanti per l’Ambient IntelligenceFulvio Corno
 
Ambient Intelligence Design Process
Ambient Intelligence Design ProcessAmbient Intelligence Design Process
Ambient Intelligence Design ProcessFulvio Corno
 
Definition of Ambient Intelligence
Definition of Ambient IntelligenceDefinition of Ambient Intelligence
Definition of Ambient IntelligenceFulvio Corno
 
Ambient Intelligence: Theme of the Year 2016
Ambient Intelligence: Theme of the Year 2016Ambient Intelligence: Theme of the Year 2016
Ambient Intelligence: Theme of the Year 2016Fulvio Corno
 
AmI 2015 - Design Process
AmI 2015 - Design ProcessAmI 2015 - Design Process
AmI 2015 - Design ProcessFulvio Corno
 
Dates and Times in Java 7 and Java 8
Dates and Times in Java 7 and Java 8Dates and Times in Java 7 and Java 8
Dates and Times in Java 7 and Java 8Fulvio Corno
 
Introduzione al Corso - Tecniche di Programmazione 2015
Introduzione al Corso - Tecniche di Programmazione 2015Introduzione al Corso - Tecniche di Programmazione 2015
Introduzione al Corso - Tecniche di Programmazione 2015Fulvio Corno
 
Indicatori quantitativi per la valutazione dei processi
Indicatori quantitativi per la valutazione dei processiIndicatori quantitativi per la valutazione dei processi
Indicatori quantitativi per la valutazione dei processiFulvio Corno
 
Designing the User Experience
Designing the User ExperienceDesigning the User Experience
Designing the User ExperienceFulvio Corno
 
A Healthcare Support System for Assisted Living Facilities: an IoT Solution
A Healthcare Support System for Assisted Living Facilities: an IoT SolutionA Healthcare Support System for Assisted Living Facilities: an IoT Solution
A Healthcare Support System for Assisted Living Facilities: an IoT SolutionFulvio Corno
 

Viewers also liked (17)

Strumenti e metodi per la preparazione dei contenuti in e-learning
 Strumenti e metodi per la preparazione dei contenuti in e-learning Strumenti e metodi per la preparazione dei contenuti in e-learning
Strumenti e metodi per la preparazione dei contenuti in e-learning
 
Introduction to Semantic Web, Metadata, Knowledge Representation, Ontologies
Introduction to Semantic Web, Metadata, Knowledge Representation, OntologiesIntroduction to Semantic Web, Metadata, Knowledge Representation, Ontologies
Introduction to Semantic Web, Metadata, Knowledge Representation, Ontologies
 
Web Architecture and Technologies
Web Architecture and TechnologiesWeb Architecture and Technologies
Web Architecture and Technologies
 
Ambient Intelligence - Course Introduction
Ambient Intelligence - Course IntroductionAmbient Intelligence - Course Introduction
Ambient Intelligence - Course Introduction
 
Introduction to JSP pages
Introduction to JSP pagesIntroduction to JSP pages
Introduction to JSP pages
 
Presentazione Laurea Magistrale in Ingegneria Informatica del Politecnico di ...
Presentazione Laurea Magistrale in Ingegneria Informatica del Politecnico di ...Presentazione Laurea Magistrale in Ingegneria Informatica del Politecnico di ...
Presentazione Laurea Magistrale in Ingegneria Informatica del Politecnico di ...
 
E-learning e teorie sull'apprendimento
 E-learning e teorie sull'apprendimento E-learning e teorie sull'apprendimento
E-learning e teorie sull'apprendimento
 
Gli anelli mancanti per l’Ambient Intelligence
Gli anelli mancanti per l’Ambient IntelligenceGli anelli mancanti per l’Ambient Intelligence
Gli anelli mancanti per l’Ambient Intelligence
 
Ambient Intelligence Design Process
Ambient Intelligence Design ProcessAmbient Intelligence Design Process
Ambient Intelligence Design Process
 
Definition of Ambient Intelligence
Definition of Ambient IntelligenceDefinition of Ambient Intelligence
Definition of Ambient Intelligence
 
Ambient Intelligence: Theme of the Year 2016
Ambient Intelligence: Theme of the Year 2016Ambient Intelligence: Theme of the Year 2016
Ambient Intelligence: Theme of the Year 2016
 
AmI 2015 - Design Process
AmI 2015 - Design ProcessAmI 2015 - Design Process
AmI 2015 - Design Process
 
Dates and Times in Java 7 and Java 8
Dates and Times in Java 7 and Java 8Dates and Times in Java 7 and Java 8
Dates and Times in Java 7 and Java 8
 
Introduzione al Corso - Tecniche di Programmazione 2015
Introduzione al Corso - Tecniche di Programmazione 2015Introduzione al Corso - Tecniche di Programmazione 2015
Introduzione al Corso - Tecniche di Programmazione 2015
 
Indicatori quantitativi per la valutazione dei processi
Indicatori quantitativi per la valutazione dei processiIndicatori quantitativi per la valutazione dei processi
Indicatori quantitativi per la valutazione dei processi
 
Designing the User Experience
Designing the User ExperienceDesigning the User Experience
Designing the User Experience
 
A Healthcare Support System for Assisted Living Facilities: an IoT Solution
A Healthcare Support System for Assisted Living Facilities: an IoT SolutionA Healthcare Support System for Assisted Living Facilities: an IoT Solution
A Healthcare Support System for Assisted Living Facilities: an IoT Solution
 

Similar to JavaFX programming

Programming with JavaFX
Programming with JavaFXProgramming with JavaFX
Programming with JavaFXFulvio Corno
 
JSUG - Filthy Flex by Christoph Pickl
JSUG - Filthy Flex by Christoph PicklJSUG - Filthy Flex by Christoph Pickl
JSUG - Filthy Flex by Christoph PicklChristoph Pickl
 
27 - Panorama Necto 14 component mode & java script - visualization & data di...
27 - Panorama Necto 14 component mode & java script - visualization & data di...27 - Panorama Necto 14 component mode & java script - visualization & data di...
27 - Panorama Necto 14 component mode & java script - visualization & data di...Panorama Software
 
Programming with JavaFX
Programming with JavaFXProgramming with JavaFX
Programming with JavaFXFulvio Corno
 
Client Side MVC & Angular
Client Side MVC & AngularClient Side MVC & Angular
Client Side MVC & AngularAlexe Bogdan
 
Design Patterns in Cocoa Touch
Design Patterns in Cocoa TouchDesign Patterns in Cocoa Touch
Design Patterns in Cocoa TouchEliah Nikans
 
Stephen Kennedy Silverlight 3 Deep Dive
Stephen Kennedy Silverlight 3 Deep DiveStephen Kennedy Silverlight 3 Deep Dive
Stephen Kennedy Silverlight 3 Deep DiveMicrosoftFeed
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applicationshchen1
 
Necto 16 training 20 component mode &amp; java script
Necto 16 training 20   component mode &amp; java scriptNecto 16 training 20   component mode &amp; java script
Necto 16 training 20 component mode &amp; java scriptPanorama Software
 
MVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCMVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCAnton Krasnoshchok
 
Effective JavaFX architecture with FxObjects
Effective JavaFX architecture with FxObjectsEffective JavaFX architecture with FxObjects
Effective JavaFX architecture with FxObjectsSrikanth Shenoy
 
Getting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with ThymeleafGetting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with ThymeleafMasatoshi Tada
 
XPages Blast - ILUG 2010
XPages Blast - ILUG 2010XPages Blast - ILUG 2010
XPages Blast - ILUG 2010Tim Clark
 
Principles of MVC for Rails Developers
Principles of MVC for Rails DevelopersPrinciples of MVC for Rails Developers
Principles of MVC for Rails DevelopersEdureka!
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfoliomwillmer
 

Similar to JavaFX programming (20)

Programming with JavaFX
Programming with JavaFXProgramming with JavaFX
Programming with JavaFX
 
JSUG - Filthy Flex by Christoph Pickl
JSUG - Filthy Flex by Christoph PicklJSUG - Filthy Flex by Christoph Pickl
JSUG - Filthy Flex by Christoph Pickl
 
27 - Panorama Necto 14 component mode & java script - visualization & data di...
27 - Panorama Necto 14 component mode & java script - visualization & data di...27 - Panorama Necto 14 component mode & java script - visualization & data di...
27 - Panorama Necto 14 component mode & java script - visualization & data di...
 
Programming with JavaFX
Programming with JavaFXProgramming with JavaFX
Programming with JavaFX
 
Client Side MVC & Angular
Client Side MVC & AngularClient Side MVC & Angular
Client Side MVC & Angular
 
Design Patterns in Cocoa Touch
Design Patterns in Cocoa TouchDesign Patterns in Cocoa Touch
Design Patterns in Cocoa Touch
 
Stephen Kennedy Silverlight 3 Deep Dive
Stephen Kennedy Silverlight 3 Deep DiveStephen Kennedy Silverlight 3 Deep Dive
Stephen Kennedy Silverlight 3 Deep Dive
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
 
Necto 16 training 20 component mode &amp; java script
Necto 16 training 20   component mode &amp; java scriptNecto 16 training 20   component mode &amp; java script
Necto 16 training 20 component mode &amp; java script
 
MVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCMVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVC
 
Effective JavaFX architecture with FxObjects
Effective JavaFX architecture with FxObjectsEffective JavaFX architecture with FxObjects
Effective JavaFX architecture with FxObjects
 
Getting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with ThymeleafGetting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with Thymeleaf
 
react-en.pdf
react-en.pdfreact-en.pdf
react-en.pdf
 
XPages Blast - ILUG 2010
XPages Blast - ILUG 2010XPages Blast - ILUG 2010
XPages Blast - ILUG 2010
 
Angular js
Angular jsAngular js
Angular js
 
Principles of MVC for Rails Developers
Principles of MVC for Rails DevelopersPrinciples of MVC for Rails Developers
Principles of MVC for Rails Developers
 
Java script best practices v4
Java script best practices v4Java script best practices v4
Java script best practices v4
 
Training On Angular Js
Training On Angular JsTraining On Angular Js
Training On Angular Js
 
Angular js
Angular jsAngular js
Angular js
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfolio
 

Recently uploaded

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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 organizationRadu Cotescu
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
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 productivityPrincipled Technologies
 
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...Enterprise Knowledge
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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 2024The Digital Insurer
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 

Recently uploaded (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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
 
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...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 

JavaFX programming

  • 1. JavaFX programming Tecniche di Programmazione – A.A. 2012/2013
  • 2. Summary 1. Model-View-Controller 2. The Controller in FXML 3. Charts 2 Tecniche di programmazione A.A. 2012/2013
  • 3. Model-View-Controller JavaFX programming
  • 4. Application complexity and MVC  Interactive, graphical applications exhibit complex interaction patterns  Flow of control is in the hand of the user  Actions are mainly asynchronous  How to organize the program?  Where to store data?  How to decouple application logic from interface details?  How to keep in sync the inner data with the visibile interface? 4 Tecniche di programmazione A.A. 2012/2013
  • 5. Media Player example 5 Tecniche di programmazione A.A. 2012/2013
  • 6. MVC pattern defined 6 Tecniche di programmazione A.A. 2012/2013
  • 7. Normal life-cycle of interaction 7 Tecniche di programmazione A.A. 2012/2013
  • 8. Mapping concepts to JavaFX  View: presenting the UI  FXML  The Nodes in the Scene Graph  Controller: reacting to user actions  Set of event handlers  Model: handling the data  Class(es) including data  Persistent data in Data Bases 8 Tecniche di programmazione A.A. 2012/2013
  • 9. Design Exercise  Imagine an application managing a list of items (e.g., names)  Different items in the user interface should manage the same set of data, with different criteria and actions  Where do you declare the data class?  Which class should have access to which?  Who creates what objects? 9 Tecniche di programmazione A.A. 2012/2013
  • 10. A possible solution 10 Tecniche di programmazione A.A. 2012/2013
  • 11. The Controller in FXML JavaFX programming
  • 12. The Controller in FXML  Several attributes in FXML help in the definition of the Controller behavior associated to a scene  Identification of the Controller class  Injection of Node identifiers (references)  Registration of event handlers  Additionally, the JavaFX Scene Builder may generate a «controller skeleton» for inclusion in the project 12 Tecniche di programmazione A.A. 2012/2013
  • 13. Defining the Controller class  The Root element of the scene graph may specify a fx: controller attribute  <BorderPane id="BorderPane" xmlns:fx="http://javafx.com /fxml" fx:controller="it.polito.te cnprogr.RuzzleController"> 13 Tecniche di programmazione A.A. 2012/2013
  • 14. fx:controller attribute  Associate a "controller" class with an FXML document  Automatically create the instance when FXML is loaded  Should include event handler methods  May include an initialize() method  public void initialize();  called once when the contents of its associated document have been completely loaded  any necessary post-processing on the content 14 Tecniche di programmazione A.A. 2012/2013
  • 15. Accessing the controller instance  The Application often needs to communicate with the controller object  E.g., to call setModel()  FXMLLoader provides this information URL location = getClass().getResource("example.fxml"); FXMLLoader fxmlLoader = new FXMLLoader(location); Pane root = (Pane)fxmlLoader.load(); MyController controller = (MyController)fxmlLoader.getController(); 15 Tecniche di programmazione A.A. 2012/2013
  • 16. Injection of Node references  The controller code may directly access various Nodes in the associated scene graph  The attribute @FXML associates a Node variable with the corresponding node, with the same fx:id value as the variable name  No more error-prone «lookup» calls...  Local variables in the controller instance  Try:View | Show Sample Controller Skeleton on the Scene Builder! @FXML // fx:id="theTitle" private Label theTitle; 16 Tecniche di programmazione A.A. 2012/2013
  • 17. Registration of Event Handlers  In FXML, you may set a event handler through attributes  onAction, onKeyTyped, onMouseClicked, ... hundreds more ...  The value should be the #name of a method in the controller class  With the right signature for the event type <Button fx:id="cercaBtn" @FXML onAction="#doCercaParola" void doCercaParola ( text="Cerca" /> ActionEvent event ) { 17 Tecniche di programmazione A.A. 2012/2013
  • 19. Resources  API  http://docs.oracle.com/javafx/2/api/index.html  FXML Controller  http://docs.oracle.com/javafx/2/api/javafx/fxml/doc- files/introduction_to_fxml.html#controllers  Books  Head First Design Patterns, chapter 12 21 Tecniche di programmazione A.A. 2012/2013
  • 20. Licenza d’uso  Queste diapositive sono distribuite con licenza Creative Commons “Attribuzione - Non commerciale - Condividi allo stesso modo (CC BY-NC-SA)”  Sei libero:  di riprodurre, distribuire, comunicare al pubblico, esporre in pubblico, rappresentare, eseguire e recitare quest'opera  di modificare quest'opera  Alle seguenti condizioni:  Attribuzione — Devi attribuire la paternità dell'opera agli autori originali e in modo tale da non suggerire che essi avallino te o il modo in cui tu usi l'opera.  Non commerciale — Non puoi usare quest'opera per fini commerciali.  Condividi allo stesso modo — Se alteri o trasformi quest'opera, o se la usi per crearne un'altra, puoi distribuire l'opera risultante solo con una licenza identica o equivalente a questa.  http://creativecommons.org/licenses/by-nc-sa/3.0/ 22 Tecniche di programmazione A.A. 2012/2013