SlideShare a Scribd company logo
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Introduction to JavaFX
on Raspberry Pi
Bruno Borges
Oracle Product Manager for Latin America
Java Evangelist
bit.ly/javafxraspberrypij1
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 132
Bruno Borges
Oracle Product Manager / Evangelist
Developer, Gamer, Beer lover
JavaFX / Embedded Enthusiast
Twitter: @brunoborges
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
What do you need to build JavaFX apps?

JavaFX Scene Builder
●
Linux supported!

Java SE 6/7/8
●
SE 8 comes with JavaFX libs as part of JRE

NetBeans 7.3.1+
Some things, and coffee
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JavaFX Scene Builder 1.1 GA
bit.ly/javafxdownload
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Raspberry Pi Configurations
for JavaFX applications
CPU Overclock
900~950MHz
Memory split
128MB for video
Framebuffer
framebuffer_width=1280
framebuffer_height=720
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
CPU Overclock
for JavaFX applications
$ cat /proc/cpuinfo
Processor : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS : 697.95
…
$ sudo raspi-config
bit.ly/raspioverclock
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
CPU Overclock
for JavaFX applications
$ cat /proc/cpuinfo
Processor : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS : 697.95
…
$ sudo raspi-config
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
CPU Overclock
for JavaFX applications
$ cat /proc/cpuinfo
Processor : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS : 697.95
…
$ sudo raspi-config
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Memory Split
for JavaFX applications
128mb best
performance
64mb may work
$ sudo raspi-config
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Memory Split
for JavaFX applications
128mb best
performance
64mb may work
$ sudo raspi-config
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Video Framebuffer
for JavaFX applications
Edit /boot/config.txt
Enable (uncomment) these options, with these values:
framebuffer_width=1280
framebuffer_height=720
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Exiting a JavaFX Application on Raspberry.Pi
Connect over SSH and kill the java process
$ killall -9 java
Enable the debug environment variable to enable control-C exit command
$ export JAVA_DEBUG=1
$ java -cp Stopwatch.jar stopwatch.MainScreen
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Final parameters for JavaFX on Raspy
Do not show virtual keyboard (optional)
-Dcom.sun.javafx.isEmbedded=false
Send video to the framebuffer (required!)
-Djavafx.platform=eglfb
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Building Your 1st
JavaFX App
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1315
Your First JavaFX App for RaspberryPi
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1316
Your First JavaFX App for RaspberryPi
public class MyApplication extends Application {
@Override
public void start(Stage stage) throws Exception {
URL fxml = getClass().getResource("MyApplication.fxml");
Parent root = FXMLLoader.load(fxml);
Scene scene = new Scene(root);
stage.setScene(scene);
stage.setFullScreen(true); // for Desktop. Not need for Pi
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1317

Properties
// JavaFX
DoubleProperty value = new SimpleDoubleProperty(0);
public double getValue() {
return value.get();
}
public void setValue(double newValue){
value.set(newValue);
}
public DoubleProperty valueProperty() {
return value;
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1318

Properties
// JavaFX
DoubleProperty value = new SimpleDoubleProperty(0);
public double getValue() {
return value.get();
}
public void setValue(double newValue){
value.set(newValue);
}
public DoubleProperty valueProperty() {
return value;
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1319

Bindings

Binding unidirecional
●
bind();

Binding bi-direcional
●
bindBidirectional();
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1320

Bindings

Binding unidirecional
●
bind();

Binding bi-direcional
●
bindBidirectional();
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1321

Bindings
@FXML
private Label humidityLabel;
...
// HUMIDITY MONITOR
HumidityMonitor humidityMon = new HumidityMonitor(...);
humidityLabel.textProperty().bind(humidityMon.valueProperty());
humidityMonitor.start();
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1322

Bindings
IntegerProperty number1 = new SimpleIntegerProperty(1);
IntegerProperty number2 = new SimpleIntegerProperty(2);
DoubleProperty number3 = new SimpleDoubleProperty(0.5);
NumberBinding sum1 = number1.add(number2);
NumberBinding result1 = number1
.add(number2)
.multiply(number3);
NumberBinding sum2 = Bindings.add(number1, number2);
NumberBinding result2 = Bindings
.add(number1,
multiply(number2, number3));
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1323

JAX-RS 2.0 Client API
Download libs from here:
bit.ly/jersey-libs-javafx
https://jersey.java.net/
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1324

JAX-RS 2.0 Client API
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
...
Client client = ClientBuilder.newClient();
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1325

JAX-RS 2.0 Client API
String uriTemplate = "http://{host}:{port}/things";
String host = System.getProperty(
"things.host",
"192.168.1.101");
String port = System.getProperty(
"things.port",
"8080");
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1326

JAX-RS 2.0 Client API
Map<String, Object> params = new HashMap<>();
params.put("host", host);
params.put("port", port);
UriBuilder uriBuilder = UriBuilder.fromUri(uriTemplate);
Client thingsServerURI = uriBuilder.buildFromMap(params);
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1327

JAX-RS 2.0 Client API
Using the things REST client
String sHumidity = thingsServerURI
.path("/humidity")
.request()
.get(String.class);
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1328

Working with Threads
Using the things REST client with threads
class MonitorService extends TimerTask {
public void run() {
String sval = thingsHumidyPath
.request().get(String.class);
final float humidity = new Float(sval);
Platform.runLater(new Runnable() {
@Override
public void run() {
floatValue.set(humidity);
value.set(Float.toString(humidity));
}
});
}
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1329

Working with Threads
Using the things REST client with threads
class MonitorService extends TimerTask {
public void run() {
String sval = thingsHumidyPath
.request().get(String.class);
final float humidity = new Float(sval);
Platform.runLater(new Runnable() {
@Override
public void run() {
this.floatValue.set(humidity);
this.value.set(Float.toString(humidity));
}
});
}
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1330

Back to the Bindings
@FXML
private Label humidityLabel;
...
// HUMIDITY MONITOR
HumidityMonitor humidityMon = new HumidityMonitor(...);
humidityLabel.textProperty().bind(humidityMon.valueProperty());
humidityMonitor.start();
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1331

Working with Threads
Using the things REST client with threads
Start the Monitoring service
Timer timer = new Timer(true);
timer.schedule(new MonitorService(), 0, DELAY);
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
QUESTIONS?
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1333
Thanks!
@brunoborges
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
The preceding is intended to outline our general product direction. It is intended
for information purposes only, and may not be incorporated into any contract.
It is not a commitment to deliver any material, code, or functionality, and should
not be relied upon in making purchasing decisions. The development, release,
and timing of any features or functionality described for Oracle’s products
remains at the sole discretion of Oracle.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

More Related Content

PDF
Java: Create The Future Keynote
PDF
JDK 9 Java Platform Module System
PDF
Tweet4Beer - Beertap powered by Java goes IoT and JavaFX
PPT
GlassFish BOF
PDF
JDK 10 Java Module System
PDF
As novidades do Java EE 7: do HTML5 ao JMS 2.0
PDF
CON5898 What Servlet 4.0 Means To You
PDF
Java API for WebSocket 1.0: Java EE 7 and GlassFish
Java: Create The Future Keynote
JDK 9 Java Platform Module System
Tweet4Beer - Beertap powered by Java goes IoT and JavaFX
GlassFish BOF
JDK 10 Java Module System
As novidades do Java EE 7: do HTML5 ao JMS 2.0
CON5898 What Servlet 4.0 Means To You
Java API for WebSocket 1.0: Java EE 7 and GlassFish

What's hot (20)

PDF
Serverless Java: JJUG CCC 2019
PDF
JavaOne 2014 BOF4241 What's Next for JSF?
PDF
Building Large Java Projects Faster: Multicore javac and Makefile integration
PPTX
Return of Rich Client Java - Brazil
PDF
JavaOne 2015 CON7547 "Beyond the Coffee Cup: Leveraging Java Runtime Technolo...
PPTX
Ed presents JSF 2.2 and WebSocket to Gameduell.
PDF
Burns jsf-confess-2015
PDF
Pushing Java EE outside of the Enterprise: Home Automation and IoT - David De...
PDF
Batch Applications for Java Platform 1.0: Java EE 7 and GlassFish
PDF
Александр Белокрылов, Александр Мироненко. Java Embedded у вас дома
PDF
Microservices and Container
PDF
How to Thrive on REST/WebSocket-Based Microservices
PDF
It's a jdk jungle out there - JDK 11 and OpenJDK 11
PDF
JSF 2.2 Input Output JavaLand 2015
PPTX
JavaFX 2 Using the Spring Framework
PPTX
GlassFish Roadmap
PPTX
JavaFX and JEE 7
PDF
WebSocket in Enterprise Applications 2015
PPTX
Ed presents JSF 2.2 at a 2013 Gameduell Tech talk
PPTX
[RakutenTechConf2013] [E-3] Financial Web System with Java EE 6
Serverless Java: JJUG CCC 2019
JavaOne 2014 BOF4241 What's Next for JSF?
Building Large Java Projects Faster: Multicore javac and Makefile integration
Return of Rich Client Java - Brazil
JavaOne 2015 CON7547 "Beyond the Coffee Cup: Leveraging Java Runtime Technolo...
Ed presents JSF 2.2 and WebSocket to Gameduell.
Burns jsf-confess-2015
Pushing Java EE outside of the Enterprise: Home Automation and IoT - David De...
Batch Applications for Java Platform 1.0: Java EE 7 and GlassFish
Александр Белокрылов, Александр Мироненко. Java Embedded у вас дома
Microservices and Container
How to Thrive on REST/WebSocket-Based Microservices
It's a jdk jungle out there - JDK 11 and OpenJDK 11
JSF 2.2 Input Output JavaLand 2015
JavaFX 2 Using the Spring Framework
GlassFish Roadmap
JavaFX and JEE 7
WebSocket in Enterprise Applications 2015
Ed presents JSF 2.2 at a 2013 Gameduell Tech talk
[RakutenTechConf2013] [E-3] Financial Web System with Java EE 6
Ad

Similar to Introduction to JavaFX on Raspberry Pi (20)

PPTX
A Importância do JavaFX no Mercado Embedded
PDF
PPTX
JavaFX 8 everywhere; write once run anywhere by Mohamed Taman
PDF
Introduction to JavaFX
PDF
JavaOne - The JavaFX Community and Ecosystem
PPT
JavaFX - Next Generation Java UI
PPTX
Complete Solution for JavaFX Development - NexSoftSys
PDF
JavaFX: A Rich Internet Application (RIA) Development Platform
PPTX
JavaFX 2 - A Java Developer's Guide (San Antonio JUG Version)
PDF
JavaFX Enterprise (JavaOne 2014)
PPTX
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
PDF
Java Fx Ajaxworld Rags V1
PDF
The Brainify App - JavaFx
PPTX
Hands on Java8 and RaspberryPi
PDF
JavaScript all the things! - FullStack 2017
PDF
Javafx tutorial
PDF
Javafx tutorial
PDF
Javafx tutorial
PDF
DataFX 8 (JavaOne 2014)
PPT
Unit 1 informatica en ingles
A Importância do JavaFX no Mercado Embedded
JavaFX 8 everywhere; write once run anywhere by Mohamed Taman
Introduction to JavaFX
JavaOne - The JavaFX Community and Ecosystem
JavaFX - Next Generation Java UI
Complete Solution for JavaFX Development - NexSoftSys
JavaFX: A Rich Internet Application (RIA) Development Platform
JavaFX 2 - A Java Developer's Guide (San Antonio JUG Version)
JavaFX Enterprise (JavaOne 2014)
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
Java Fx Ajaxworld Rags V1
The Brainify App - JavaFx
Hands on Java8 and RaspberryPi
JavaScript all the things! - FullStack 2017
Javafx tutorial
Javafx tutorial
Javafx tutorial
DataFX 8 (JavaOne 2014)
Unit 1 informatica en ingles
Ad

More from Bruno Borges (20)

PDF
Secrets of Performance Tuning Java on Kubernetes
PDF
[Outdated] Secrets of Performance Tuning Java on Kubernetes
PDF
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
PDF
Making Sense of Serverless Computing
PPTX
Visual Studio Code for Java and Spring Developers
PDF
Taking Spring Apps for a Spin on Microsoft Azure Cloud
PDF
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
PPTX
Melhore o Desenvolvimento do Time com DevOps na Nuvem
PPTX
Tecnologias Oracle em Docker Containers On-premise e na Nuvem
PPTX
Java EE Arquillian Testing with Docker & The Cloud
PPTX
Migrating From Applets to Java Desktop Apps in JavaFX
PDF
Servidores de Aplicação: Por quê ainda precisamos deles?
PDF
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
PDF
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
PDF
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
PDF
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
PDF
Running Oracle WebLogic on Docker Containers [BOF7537]
PPTX
Lightweight Java in the Cloud
PDF
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
PDF
Integrando Oracle BPM com Java EE e WebSockets
Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
Making Sense of Serverless Computing
Visual Studio Code for Java and Spring Developers
Taking Spring Apps for a Spin on Microsoft Azure Cloud
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
Melhore o Desenvolvimento do Time com DevOps na Nuvem
Tecnologias Oracle em Docker Containers On-premise e na Nuvem
Java EE Arquillian Testing with Docker & The Cloud
Migrating From Applets to Java Desktop Apps in JavaFX
Servidores de Aplicação: Por quê ainda precisamos deles?
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Running Oracle WebLogic on Docker Containers [BOF7537]
Lightweight Java in the Cloud
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Integrando Oracle BPM com Java EE e WebSockets

Recently uploaded (20)

PDF
Empathic Computing: Creating Shared Understanding
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPT
Teaching material agriculture food technology
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Approach and Philosophy of On baking technology
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Machine learning based COVID-19 study performance prediction
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Electronic commerce courselecture one. Pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Spectroscopy.pptx food analysis technology
Empathic Computing: Creating Shared Understanding
gpt5_lecture_notes_comprehensive_20250812015547.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Teaching material agriculture food technology
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Approach and Philosophy of On baking technology
Diabetes mellitus diagnosis method based random forest with bat algorithm
Agricultural_Statistics_at_a_Glance_2022_0.pdf
sap open course for s4hana steps from ECC to s4
Machine learning based COVID-19 study performance prediction
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Encapsulation_ Review paper, used for researhc scholars
Assigned Numbers - 2025 - Bluetooth® Document
Unlocking AI with Model Context Protocol (MCP)
Electronic commerce courselecture one. Pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Spectroscopy.pptx food analysis technology

Introduction to JavaFX on Raspberry Pi

  • 1. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Introduction to JavaFX on Raspberry Pi Bruno Borges Oracle Product Manager for Latin America Java Evangelist bit.ly/javafxraspberrypij1
  • 2. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 132 Bruno Borges Oracle Product Manager / Evangelist Developer, Gamer, Beer lover JavaFX / Embedded Enthusiast Twitter: @brunoborges
  • 3. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. What do you need to build JavaFX apps?  JavaFX Scene Builder ● Linux supported!  Java SE 6/7/8 ● SE 8 comes with JavaFX libs as part of JRE  NetBeans 7.3.1+ Some things, and coffee
  • 4. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. JavaFX Scene Builder 1.1 GA bit.ly/javafxdownload
  • 5. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Raspberry Pi Configurations for JavaFX applications CPU Overclock 900~950MHz Memory split 128MB for video Framebuffer framebuffer_width=1280 framebuffer_height=720
  • 6. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. CPU Overclock for JavaFX applications $ cat /proc/cpuinfo Processor : ARMv6-compatible processor rev 7 (v6l) BogoMIPS : 697.95 … $ sudo raspi-config bit.ly/raspioverclock
  • 7. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. CPU Overclock for JavaFX applications $ cat /proc/cpuinfo Processor : ARMv6-compatible processor rev 7 (v6l) BogoMIPS : 697.95 … $ sudo raspi-config
  • 8. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. CPU Overclock for JavaFX applications $ cat /proc/cpuinfo Processor : ARMv6-compatible processor rev 7 (v6l) BogoMIPS : 697.95 … $ sudo raspi-config
  • 9. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Memory Split for JavaFX applications 128mb best performance 64mb may work $ sudo raspi-config
  • 10. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Memory Split for JavaFX applications 128mb best performance 64mb may work $ sudo raspi-config
  • 11. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Video Framebuffer for JavaFX applications Edit /boot/config.txt Enable (uncomment) these options, with these values: framebuffer_width=1280 framebuffer_height=720
  • 12. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Exiting a JavaFX Application on Raspberry.Pi Connect over SSH and kill the java process $ killall -9 java Enable the debug environment variable to enable control-C exit command $ export JAVA_DEBUG=1 $ java -cp Stopwatch.jar stopwatch.MainScreen
  • 13. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Final parameters for JavaFX on Raspy Do not show virtual keyboard (optional) -Dcom.sun.javafx.isEmbedded=false Send video to the framebuffer (required!) -Djavafx.platform=eglfb
  • 14. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Building Your 1st JavaFX App
  • 15. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1315 Your First JavaFX App for RaspberryPi
  • 16. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1316 Your First JavaFX App for RaspberryPi public class MyApplication extends Application { @Override public void start(Stage stage) throws Exception { URL fxml = getClass().getResource("MyApplication.fxml"); Parent root = FXMLLoader.load(fxml); Scene scene = new Scene(root); stage.setScene(scene); stage.setFullScreen(true); // for Desktop. Not need for Pi stage.show(); } public static void main(String[] args) { launch(args); } }
  • 17. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1317  Properties // JavaFX DoubleProperty value = new SimpleDoubleProperty(0); public double getValue() { return value.get(); } public void setValue(double newValue){ value.set(newValue); } public DoubleProperty valueProperty() { return value; }
  • 18. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1318  Properties // JavaFX DoubleProperty value = new SimpleDoubleProperty(0); public double getValue() { return value.get(); } public void setValue(double newValue){ value.set(newValue); } public DoubleProperty valueProperty() { return value; }
  • 19. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1319  Bindings  Binding unidirecional ● bind();  Binding bi-direcional ● bindBidirectional();
  • 20. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1320  Bindings  Binding unidirecional ● bind();  Binding bi-direcional ● bindBidirectional();
  • 21. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1321  Bindings @FXML private Label humidityLabel; ... // HUMIDITY MONITOR HumidityMonitor humidityMon = new HumidityMonitor(...); humidityLabel.textProperty().bind(humidityMon.valueProperty()); humidityMonitor.start();
  • 22. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1322  Bindings IntegerProperty number1 = new SimpleIntegerProperty(1); IntegerProperty number2 = new SimpleIntegerProperty(2); DoubleProperty number3 = new SimpleDoubleProperty(0.5); NumberBinding sum1 = number1.add(number2); NumberBinding result1 = number1 .add(number2) .multiply(number3); NumberBinding sum2 = Bindings.add(number1, number2); NumberBinding result2 = Bindings .add(number1, multiply(number2, number3));
  • 23. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1323  JAX-RS 2.0 Client API Download libs from here: bit.ly/jersey-libs-javafx https://jersey.java.net/
  • 24. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1324  JAX-RS 2.0 Client API import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; ... Client client = ClientBuilder.newClient();
  • 25. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1325  JAX-RS 2.0 Client API String uriTemplate = "http://{host}:{port}/things"; String host = System.getProperty( "things.host", "192.168.1.101"); String port = System.getProperty( "things.port", "8080");
  • 26. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1326  JAX-RS 2.0 Client API Map<String, Object> params = new HashMap<>(); params.put("host", host); params.put("port", port); UriBuilder uriBuilder = UriBuilder.fromUri(uriTemplate); Client thingsServerURI = uriBuilder.buildFromMap(params);
  • 27. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1327  JAX-RS 2.0 Client API Using the things REST client String sHumidity = thingsServerURI .path("/humidity") .request() .get(String.class);
  • 28. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1328  Working with Threads Using the things REST client with threads class MonitorService extends TimerTask { public void run() { String sval = thingsHumidyPath .request().get(String.class); final float humidity = new Float(sval); Platform.runLater(new Runnable() { @Override public void run() { floatValue.set(humidity); value.set(Float.toString(humidity)); } }); } }
  • 29. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1329  Working with Threads Using the things REST client with threads class MonitorService extends TimerTask { public void run() { String sval = thingsHumidyPath .request().get(String.class); final float humidity = new Float(sval); Platform.runLater(new Runnable() { @Override public void run() { this.floatValue.set(humidity); this.value.set(Float.toString(humidity)); } }); } }
  • 30. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1330  Back to the Bindings @FXML private Label humidityLabel; ... // HUMIDITY MONITOR HumidityMonitor humidityMon = new HumidityMonitor(...); humidityLabel.textProperty().bind(humidityMon.valueProperty()); humidityMonitor.start();
  • 31. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1331  Working with Threads Using the things REST client with threads Start the Monitoring service Timer timer = new Timer(true); timer.schedule(new MonitorService(), 0, DELAY);
  • 32. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. QUESTIONS?
  • 33. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1333 Thanks! @brunoborges
  • 34. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
  • 35. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.