SlideShare uma empresa Scribd logo
1 de 53
Baixar para ler offline
Construire une application JavaFX 8 avec 
gradle
Construire une application JavaFX 8 avec gradle 
Thierry Wasylczenko 
@twasyl 
La session trendy
3
Ce dont on va parler 
• JavaFX 8 
• gradle 
• Tooling 
• De code 
4
5 
#JavaFX 8: 
De 2 à 8
Les Properties
Les types 
8 
IntegerProperty intP = new SimpleIntegerProperty(); 
DoubleProperty doubleP = new SimpleDoubleProperty(); 
// ... 
BooleanProperty booleanP = new SimpleBooleanProperty(); 
StringProperty stringP = new SimpleStringProperty(); 
ObjectProperty<SoftShake> objectP = new SimpleObjectProperty();
Le binding 
IntegerProperty intP1 = new SimpleIntegerProperty(); 
IntegerProperty intP2 = new SimpleIntegerProperty(); 
intP1.bind(intP2); 
intP2.set(10); 
System.out.println("Et P1? " + intP1.get()); 
9
Le binding 
IntegerProperty intP1 = new SimpleIntegerProperty(); 
IntegerProperty intP2 = new SimpleIntegerProperty(); 
intP1.bindBidirectional(intP2); 
intP2.set(10); 
System.out.println("Et P1? " + intP1.get()); 
intP1.set(20); 
System.out.println("Et P2? " + intP2.get()); 
10
Les événements 
IntegerProperty intP1 = new SimpleIntegerProperty(); 
intP1.addListener((valueInt, oldInt, newInt) -> { 
System.out.println("Change"); 
}); 
intP1.set(10); 
11
POJO 2.0 
public class Conference { 
private StringProperty name = new SimpleStringProperty(); 
12 
public StringProperty nameProperty() { return this.name; } 
public String getName() { return this.name.get(); } 
public void setName(String name) { this.name.set(name); } 
} 
final Conference softShake = new Conference(); 
tf.textProperty().bindBidirectional(softShake.nameProperty());
Pas serializable
POJO 1.5 
public class Conference { 
private PropertyChangeStatus pcs = 
new PropertyChangeStatus(this); 
private String name; 
public void addPropertyChangeListener(PropertyChangeListener listener) 
this.pcs.addPropertyChangeListener(listener); 
} 
public void removePropertyChangeListener(PropertyChangeListener listener) 
this.pcs.removePropertyChangeListener(listener); 
14
POJO 1.5 
final Conference softShake = new Conference(); 
JavaBeanStringPropertyBuilder builder = new ... 
JavaBeanStringProperty nameProperty = builder.bean(softShake) 
.name("name") 
.build(); 
nameProperty.addListener((valueName, oldIName, newName) -> { 
// ... 
}); 
15
Vues
FXML 
<AnchorPane xmlns:fx="http://javafx.com/fxml" 
fx:controller="org.mycompany.Controller"> 
<stylesheets> 
<URL value="@/org/mycompany/css/Default.css" /> 
<URL value="@/org/mycompany/css/Specialized.css" /> 
</stylesheets> 
<Button fx:id="myButton" text="Button" onAction="#click" /> 
<TextField fx:id="myTextField" promptText="Enter something" /> 
</AnchorPane> 
17
Controller 
public class Controller implements Initializable { 
@FXML private Button myButton; 
@FXML private TextField myTextField; 
@FXML private void click(ActionEvent evt) { /* ... */ } 
@Override 
public void initialize(URL url, ResourceBundle resourceBundle) 
// ... 
} 
} 
18
CSS
Personnaliser les composants 
FXML 
<Button style="-fx-text-fill: white" styleClass="awesome" /> 
Java 
button.setStyle("-fx-background-color: red;"); 
button.getStyleClass().add("awesome"); 
20
Personnaliser les composants 
Feuille de style 
.button { 
-fx-text-fill: white; 
-fx-background-color: red; 
} 
.button:hover { -fx-background-color: blue; } 
.awesome { -fx-background-color: gray; } 
#myButton { -fx-text-fill: black; } 
21
PseudoState personnalisés 
PseudoClass ps = PseudoClass.getPseudoClass("awesome"); 
myButton.pseudoClassStateChanged(ps, true); 
.button:awesome { 
-fx-text-fill: orange; 
} 
#myButton:awesome { 
-fx-text-fill: green; 
} 
22
WebView
JS <> JFX 
webview.getEngine().getLoadWorker().stateProperty().addListener((observableValue, if (newState == Worker.State.SUCCEEDED) { 
JSObject window = (JSObject) webview.getEngine() 
.executeScript("window"); 
window.setMember("javaObj",this); 
} 
}); 
24
JS <> JFX 
Java 
WebEngine engine = webview.getEngine(); 
String result = engine.executeScript("return 'Hello';"); 
JavaScript 
javaObj.myWonderfulMethod("Hello"); 
25
WebSocket 
window.onload = function() { 
socket = new WebSocket("ws://mycompany.com/ws"); 
socket.onopen = function(event) { /* ... */ }; 
socket.onclose = function(event) { /* ... */ }; 
socket.onmessage = function(event) { /* ... */ }; 
}; 
26
Drag'n'drop
Drag'n'drop 
obj.setOnDragDetected(event -> { /* ... */ }); 
obj.setOnDragOver(event -> { /* ... */ }); 
obj.setOnDragEntered(event -> { /* ... */ }); 
obj.setOnDragExited(event -> { /* ... */ }); 
obj.setOnDragDropped(event -> { /* ... */ }); 
obj.setOnDragDone(event -> { /* ... */ }); 
28
Printing API
Print 
Chaque Node 
PrinterJob job = PrinterJob.createPrinterJob(); 
job.printPage(myTextField); 
Une page web 
WebView view = new WebView(); 
PrinterJob job = PrinterJob.createPrinterJob(); 
view.getEngine().print(job); 
30
3D
Objets prédéfinis 
Box b = new Box(width, height, depth); 
Cylinder c = new Cylinder(radius, height); 
Sphere s = new Sphere(radius); 
TriangleMesh tm = new TriangleMesh(); 
Les plus basiques 
32
Camera & Light 
Camera camera = new PerspectiveCamera(true); 
scene.setCamera(camera); 
PointLight point = new PointLight(Color.RED); 
AmbientLight ambient = new AmbientLight(Color.WHITE); 
scene.getRoot().getChildren().addAll(point, ambient); 
Ne pas oublier de positionner les objets 
33
34 
#gradle: 
Flexibilité
Task 
• Réponds à MON besoin 
• Dynamisme 
• Dépendances 
• Greffage au cycle de vie 
task sofshake << { 
println 'Hello Soft-Shake 2014' 
} 
tasks['sofshake'].dependsOn 'jar' 
36
Task: surcharge 
apply plugin: 'java' 
task jar(overwrite: true) << { 
// ... 
manifest { 
// ... 
} 
} 
37
Dépendances 
dependencies { 
compile (':my-project') 
runtime files('libs/a.jar', 'libs/b.jar') 
runtime "org.groovy:groovy:2.2.0@jar" 
runtime group: 'org.groovy', name: 'groovy', version: '2.2.0', ext: 
} 
38
Copy 
• Copier des fichiers facilement 
• La roue est déjà inventée 
copy { 
from file1 
from file2 
into folder 
} 
39
Gradle wrapper 
• Execution de gradle sans intallation préalable 
• Plateformes d’intégration continue friendly 
task buildGradleWrapper(type: Wrapper) { 
gradleVersion = '2.1' 
} 
40
Ouvert
Intégration de Ant 
• Variables 
• Tâches 
ant.importBuild "ant/project/file.xml" 
ant.conference = "Soft-Shake 2014" 
ant.location = "Genève" 
maTacheAnt.execute() 
44
45 
Tooling
SceneBuilder 46
ScenicView 47
TestFX 
public class DesktopTest extends GuiTest { 
public Parent getRootNode() { return new Desktop(); } 
@Test public void testMe() { 
// Given 
rightClick("#desktop").move("New").click("Text Document") 
.type("myTextfile.txt").push(ENTER); 
// When 
drag(".file").to("#trash-can"); 
// Then 
verifyThat("#desktop", contains(0, ".file")); 
48
49 
#Code
Codons ! 
• JavaFX 8 
• Properties 
• FXML 
• Styling 
• gradle 
• Dépendances 
• Build 
50
Ressources 51
Ressources 
• https://github.com/TestFX/TestFX 
• http://fxexperience.com/ 
• http://fxexperience.com/controlsfx/ 
• Source code of the demo: https://bitbucket.org/twasyl/weatherfx 
52
53

Mais conteúdo relacionado

Mais procurados

JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 SpringKiyotaka Oku
 
The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212Mahmoud Samir Fayed
 
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloading
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloadingRiga DevDays 2017 - The hitchhiker’s guide to Java class reloading
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloadingAnton Arhipov
 
Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011Anton Arhipov
 
Redux for ReactJS Programmers
Redux for ReactJS ProgrammersRedux for ReactJS Programmers
Redux for ReactJS ProgrammersDavid Rodenas
 
JEEConf 2017 - The hitchhiker’s guide to Java class reloading
JEEConf 2017 - The hitchhiker’s guide to Java class reloadingJEEConf 2017 - The hitchhiker’s guide to Java class reloading
JEEConf 2017 - The hitchhiker’s guide to Java class reloadingAnton Arhipov
 
Concurrency Concepts in Java
Concurrency Concepts in JavaConcurrency Concepts in Java
Concurrency Concepts in JavaDoug Hawkins
 
Unit testing without Robolectric, Droidcon Berlin 2016
Unit testing without Robolectric, Droidcon Berlin 2016Unit testing without Robolectric, Droidcon Berlin 2016
Unit testing without Robolectric, Droidcon Berlin 2016Danny Preussler
 
Слава Бобик «NancyFx для самых маленьких»
Слава Бобик «NancyFx для самых маленьких»Слава Бобик «NancyFx для самых маленьких»
Слава Бобик «NancyFx для самых маленьких»SpbDotNet Community
 
The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189Mahmoud Samir Fayed
 
Demystifying dependency Injection: Dagger and Toothpick
Demystifying dependency Injection: Dagger and ToothpickDemystifying dependency Injection: Dagger and Toothpick
Demystifying dependency Injection: Dagger and ToothpickDanny Preussler
 
Amazon Cognito使って認証したい?それならSpring Security使いましょう!
Amazon Cognito使って認証したい?それならSpring Security使いましょう!Amazon Cognito使って認証したい?それならSpring Security使いましょう!
Amazon Cognito使って認証したい?それならSpring Security使いましょう!Ryosuke Uchitate
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good TestsTomek Kaczanowski
 
The Ring programming language version 1.5.2 book - Part 76 of 181
The Ring programming language version 1.5.2 book - Part 76 of 181The Ring programming language version 1.5.2 book - Part 76 of 181
The Ring programming language version 1.5.2 book - Part 76 of 181Mahmoud Samir Fayed
 
Cleanup and new optimizations in WPython 1.1
Cleanup and new optimizations in WPython 1.1Cleanup and new optimizations in WPython 1.1
Cleanup and new optimizations in WPython 1.1PyCon Italia
 
Exercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera CymbronExercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera Cymbroncymbron
 
Java Performance Puzzlers
Java Performance PuzzlersJava Performance Puzzlers
Java Performance PuzzlersDoug Hawkins
 
Csw2016 gawlik bypassing_differentdefenseschemes
Csw2016 gawlik bypassing_differentdefenseschemesCsw2016 gawlik bypassing_differentdefenseschemes
Csw2016 gawlik bypassing_differentdefenseschemesCanSecWest
 

Mais procurados (20)

JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 Spring
 
The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212
 
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloading
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloadingRiga DevDays 2017 - The hitchhiker’s guide to Java class reloading
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloading
 
Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011
 
Redux for ReactJS Programmers
Redux for ReactJS ProgrammersRedux for ReactJS Programmers
Redux for ReactJS Programmers
 
JEEConf 2017 - The hitchhiker’s guide to Java class reloading
JEEConf 2017 - The hitchhiker’s guide to Java class reloadingJEEConf 2017 - The hitchhiker’s guide to Java class reloading
JEEConf 2017 - The hitchhiker’s guide to Java class reloading
 
Concurrency Concepts in Java
Concurrency Concepts in JavaConcurrency Concepts in Java
Concurrency Concepts in Java
 
Unit testing without Robolectric, Droidcon Berlin 2016
Unit testing without Robolectric, Droidcon Berlin 2016Unit testing without Robolectric, Droidcon Berlin 2016
Unit testing without Robolectric, Droidcon Berlin 2016
 
Слава Бобик «NancyFx для самых маленьких»
Слава Бобик «NancyFx для самых маленьких»Слава Бобик «NancyFx для самых маленьких»
Слава Бобик «NancyFx для самых маленьких»
 
The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189
 
Testing with Node.js
Testing with Node.jsTesting with Node.js
Testing with Node.js
 
Demystifying dependency Injection: Dagger and Toothpick
Demystifying dependency Injection: Dagger and ToothpickDemystifying dependency Injection: Dagger and Toothpick
Demystifying dependency Injection: Dagger and Toothpick
 
droidparts
droidpartsdroidparts
droidparts
 
Amazon Cognito使って認証したい?それならSpring Security使いましょう!
Amazon Cognito使って認証したい?それならSpring Security使いましょう!Amazon Cognito使って認証したい?それならSpring Security使いましょう!
Amazon Cognito使って認証したい?それならSpring Security使いましょう!
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests
 
The Ring programming language version 1.5.2 book - Part 76 of 181
The Ring programming language version 1.5.2 book - Part 76 of 181The Ring programming language version 1.5.2 book - Part 76 of 181
The Ring programming language version 1.5.2 book - Part 76 of 181
 
Cleanup and new optimizations in WPython 1.1
Cleanup and new optimizations in WPython 1.1Cleanup and new optimizations in WPython 1.1
Cleanup and new optimizations in WPython 1.1
 
Exercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera CymbronExercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera Cymbron
 
Java Performance Puzzlers
Java Performance PuzzlersJava Performance Puzzlers
Java Performance Puzzlers
 
Csw2016 gawlik bypassing_differentdefenseschemes
Csw2016 gawlik bypassing_differentdefenseschemesCsw2016 gawlik bypassing_differentdefenseschemes
Csw2016 gawlik bypassing_differentdefenseschemes
 

Semelhante a Construire une application JavaFX 8 avec gradle

Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsAzul Systems, Inc.
 
Dropwizard and Friends
Dropwizard and FriendsDropwizard and Friends
Dropwizard and FriendsYun Zhi Lin
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?Doug Hawkins
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing UpDavid Padbury
 
Taking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the ExtremeTaking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the Extremeyinonavraham
 
In the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleIn the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleSkills Matter
 
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Tsuyoshi Yamamoto
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyDavid Padbury
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesAnkit Rastogi
 
Vaadin 7 Today and Tomorrow
Vaadin 7 Today and TomorrowVaadin 7 Today and Tomorrow
Vaadin 7 Today and TomorrowJoonas Lehtinen
 
Javascript Everywhere
Javascript EverywhereJavascript Everywhere
Javascript EverywherePascal Rettig
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVMSylvain Wallez
 
Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stackTomáš Kypta
 
Eric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build systemEric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build systemGuardSquare
 

Semelhante a Construire une application JavaFX 8 avec gradle (20)

Spring Boot
Spring BootSpring Boot
Spring Boot
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
 
Vaadin7
Vaadin7Vaadin7
Vaadin7
 
Dropwizard and Friends
Dropwizard and FriendsDropwizard and Friends
Dropwizard and Friends
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
Taking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the ExtremeTaking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the Extreme
 
In the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleIn the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: Gradle
 
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
 
Griffon @ Svwjug
Griffon @ SvwjugGriffon @ Svwjug
Griffon @ Svwjug
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
 
Vaadin 7
Vaadin 7Vaadin 7
Vaadin 7
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
 
Vaadin 7 Today and Tomorrow
Vaadin 7 Today and TomorrowVaadin 7 Today and Tomorrow
Vaadin 7 Today and Tomorrow
 
Javascript Everywhere
Javascript EverywhereJavascript Everywhere
Javascript Everywhere
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVM
 
Js tacktalk team dev js testing performance
Js tacktalk team dev js testing performanceJs tacktalk team dev js testing performance
Js tacktalk team dev js testing performance
 
Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stack
 
Serverless Java on Kubernetes
Serverless Java on KubernetesServerless Java on Kubernetes
Serverless Java on Kubernetes
 
Eric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build systemEric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build system
 

Mais de Thierry Wasylczenko

Du développement à la livraison avec JavaFX et le JDK9
Du développement à la livraison avec JavaFX et le JDK9Du développement à la livraison avec JavaFX et le JDK9
Du développement à la livraison avec JavaFX et le JDK9Thierry Wasylczenko
 
#Polyglottisme, une autre manière de développer une application
#Polyglottisme, une autre manière de développer une application#Polyglottisme, une autre manière de développer une application
#Polyglottisme, une autre manière de développer une applicationThierry Wasylczenko
 

Mais de Thierry Wasylczenko (7)

Du développement à la livraison avec JavaFX et le JDK9
Du développement à la livraison avec JavaFX et le JDK9Du développement à la livraison avec JavaFX et le JDK9
Du développement à la livraison avec JavaFX et le JDK9
 
JavaFX et le JDK9
JavaFX et le JDK9JavaFX et le JDK9
JavaFX et le JDK9
 
#JavaFX.forReal()
#JavaFX.forReal()#JavaFX.forReal()
#JavaFX.forReal()
 
#Polyglottisme, une autre manière de développer une application
#Polyglottisme, une autre manière de développer une application#Polyglottisme, une autre manière de développer une application
#Polyglottisme, une autre manière de développer une application
 
Java goes wild, lesson 1
Java goes wild, lesson 1Java goes wild, lesson 1
Java goes wild, lesson 1
 
JavaFX, because you're worth it
JavaFX, because you're worth itJavaFX, because you're worth it
JavaFX, because you're worth it
 
Introduction to JavaFX 2
Introduction to JavaFX 2Introduction to JavaFX 2
Introduction to JavaFX 2
 

Último

Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
DM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in projectDM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in projectssuserb6619e
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Coursebim.edu.pl
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
home automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadhome automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadaditya806802
 
Ch10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdfCh10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdfChristianCDAM
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgUnit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgsaravananr517913
 
Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptNarmatha D
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxsiddharthjain2303
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
Crystal Structure analysis and detailed information pptx
Crystal Structure analysis and detailed information pptxCrystal Structure analysis and detailed information pptx
Crystal Structure analysis and detailed information pptxachiever3003
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxRomil Mishra
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 

Último (20)

Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
DM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in projectDM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in project
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Course
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
home automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadhome automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasad
 
Designing pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptxDesigning pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptx
 
Ch10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdfCh10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdf
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgUnit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
 
Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.ppt
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptx
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
Crystal Structure analysis and detailed information pptx
Crystal Structure analysis and detailed information pptxCrystal Structure analysis and detailed information pptx
Crystal Structure analysis and detailed information pptx
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptx
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 

Construire une application JavaFX 8 avec gradle

  • 1. Construire une application JavaFX 8 avec gradle
  • 2. Construire une application JavaFX 8 avec gradle Thierry Wasylczenko @twasyl La session trendy
  • 3. 3
  • 4. Ce dont on va parler • JavaFX 8 • gradle • Tooling • De code 4
  • 8. Les types 8 IntegerProperty intP = new SimpleIntegerProperty(); DoubleProperty doubleP = new SimpleDoubleProperty(); // ... BooleanProperty booleanP = new SimpleBooleanProperty(); StringProperty stringP = new SimpleStringProperty(); ObjectProperty<SoftShake> objectP = new SimpleObjectProperty();
  • 9. Le binding IntegerProperty intP1 = new SimpleIntegerProperty(); IntegerProperty intP2 = new SimpleIntegerProperty(); intP1.bind(intP2); intP2.set(10); System.out.println("Et P1? " + intP1.get()); 9
  • 10. Le binding IntegerProperty intP1 = new SimpleIntegerProperty(); IntegerProperty intP2 = new SimpleIntegerProperty(); intP1.bindBidirectional(intP2); intP2.set(10); System.out.println("Et P1? " + intP1.get()); intP1.set(20); System.out.println("Et P2? " + intP2.get()); 10
  • 11. Les événements IntegerProperty intP1 = new SimpleIntegerProperty(); intP1.addListener((valueInt, oldInt, newInt) -> { System.out.println("Change"); }); intP1.set(10); 11
  • 12. POJO 2.0 public class Conference { private StringProperty name = new SimpleStringProperty(); 12 public StringProperty nameProperty() { return this.name; } public String getName() { return this.name.get(); } public void setName(String name) { this.name.set(name); } } final Conference softShake = new Conference(); tf.textProperty().bindBidirectional(softShake.nameProperty());
  • 14. POJO 1.5 public class Conference { private PropertyChangeStatus pcs = new PropertyChangeStatus(this); private String name; public void addPropertyChangeListener(PropertyChangeListener listener) this.pcs.addPropertyChangeListener(listener); } public void removePropertyChangeListener(PropertyChangeListener listener) this.pcs.removePropertyChangeListener(listener); 14
  • 15. POJO 1.5 final Conference softShake = new Conference(); JavaBeanStringPropertyBuilder builder = new ... JavaBeanStringProperty nameProperty = builder.bean(softShake) .name("name") .build(); nameProperty.addListener((valueName, oldIName, newName) -> { // ... }); 15
  • 16. Vues
  • 17. FXML <AnchorPane xmlns:fx="http://javafx.com/fxml" fx:controller="org.mycompany.Controller"> <stylesheets> <URL value="@/org/mycompany/css/Default.css" /> <URL value="@/org/mycompany/css/Specialized.css" /> </stylesheets> <Button fx:id="myButton" text="Button" onAction="#click" /> <TextField fx:id="myTextField" promptText="Enter something" /> </AnchorPane> 17
  • 18. Controller public class Controller implements Initializable { @FXML private Button myButton; @FXML private TextField myTextField; @FXML private void click(ActionEvent evt) { /* ... */ } @Override public void initialize(URL url, ResourceBundle resourceBundle) // ... } } 18
  • 19. CSS
  • 20. Personnaliser les composants FXML <Button style="-fx-text-fill: white" styleClass="awesome" /> Java button.setStyle("-fx-background-color: red;"); button.getStyleClass().add("awesome"); 20
  • 21. Personnaliser les composants Feuille de style .button { -fx-text-fill: white; -fx-background-color: red; } .button:hover { -fx-background-color: blue; } .awesome { -fx-background-color: gray; } #myButton { -fx-text-fill: black; } 21
  • 22. PseudoState personnalisés PseudoClass ps = PseudoClass.getPseudoClass("awesome"); myButton.pseudoClassStateChanged(ps, true); .button:awesome { -fx-text-fill: orange; } #myButton:awesome { -fx-text-fill: green; } 22
  • 24. JS <> JFX webview.getEngine().getLoadWorker().stateProperty().addListener((observableValue, if (newState == Worker.State.SUCCEEDED) { JSObject window = (JSObject) webview.getEngine() .executeScript("window"); window.setMember("javaObj",this); } }); 24
  • 25. JS <> JFX Java WebEngine engine = webview.getEngine(); String result = engine.executeScript("return 'Hello';"); JavaScript javaObj.myWonderfulMethod("Hello"); 25
  • 26. WebSocket window.onload = function() { socket = new WebSocket("ws://mycompany.com/ws"); socket.onopen = function(event) { /* ... */ }; socket.onclose = function(event) { /* ... */ }; socket.onmessage = function(event) { /* ... */ }; }; 26
  • 28. Drag'n'drop obj.setOnDragDetected(event -> { /* ... */ }); obj.setOnDragOver(event -> { /* ... */ }); obj.setOnDragEntered(event -> { /* ... */ }); obj.setOnDragExited(event -> { /* ... */ }); obj.setOnDragDropped(event -> { /* ... */ }); obj.setOnDragDone(event -> { /* ... */ }); 28
  • 30. Print Chaque Node PrinterJob job = PrinterJob.createPrinterJob(); job.printPage(myTextField); Une page web WebView view = new WebView(); PrinterJob job = PrinterJob.createPrinterJob(); view.getEngine().print(job); 30
  • 31. 3D
  • 32. Objets prédéfinis Box b = new Box(width, height, depth); Cylinder c = new Cylinder(radius, height); Sphere s = new Sphere(radius); TriangleMesh tm = new TriangleMesh(); Les plus basiques 32
  • 33. Camera & Light Camera camera = new PerspectiveCamera(true); scene.setCamera(camera); PointLight point = new PointLight(Color.RED); AmbientLight ambient = new AmbientLight(Color.WHITE); scene.getRoot().getChildren().addAll(point, ambient); Ne pas oublier de positionner les objets 33
  • 36. Task • Réponds à MON besoin • Dynamisme • Dépendances • Greffage au cycle de vie task sofshake << { println 'Hello Soft-Shake 2014' } tasks['sofshake'].dependsOn 'jar' 36
  • 37. Task: surcharge apply plugin: 'java' task jar(overwrite: true) << { // ... manifest { // ... } } 37
  • 38. Dépendances dependencies { compile (':my-project') runtime files('libs/a.jar', 'libs/b.jar') runtime "org.groovy:groovy:2.2.0@jar" runtime group: 'org.groovy', name: 'groovy', version: '2.2.0', ext: } 38
  • 39. Copy • Copier des fichiers facilement • La roue est déjà inventée copy { from file1 from file2 into folder } 39
  • 40. Gradle wrapper • Execution de gradle sans intallation préalable • Plateformes d’intégration continue friendly task buildGradleWrapper(type: Wrapper) { gradleVersion = '2.1' } 40
  • 42.
  • 43.
  • 44. Intégration de Ant • Variables • Tâches ant.importBuild "ant/project/file.xml" ant.conference = "Soft-Shake 2014" ant.location = "Genève" maTacheAnt.execute() 44
  • 48. TestFX public class DesktopTest extends GuiTest { public Parent getRootNode() { return new Desktop(); } @Test public void testMe() { // Given rightClick("#desktop").move("New").click("Text Document") .type("myTextfile.txt").push(ENTER); // When drag(".file").to("#trash-can"); // Then verifyThat("#desktop", contains(0, ".file")); 48
  • 50. Codons ! • JavaFX 8 • Properties • FXML • Styling • gradle • Dépendances • Build 50
  • 52. Ressources • https://github.com/TestFX/TestFX • http://fxexperience.com/ • http://fxexperience.com/controlsfx/ • Source code of the demo: https://bitbucket.org/twasyl/weatherfx 52
  • 53. 53