50
JAVAFX 8 MOHAMAD TAMAN Enterprise Architect & Software Development Manager Efinance, Cairo, Egypt. Write once, run everywhere

JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

Embed Size (px)

Citation preview

Page 1: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX 8MOHAMAD TAMANEnterprise Architect & Software Development ManagerEfinance, Cairo, Egypt.

Write once, run everywhere

Page 2: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

ABOUT ME

JCP, Java Champions, Was JCP EC, won the 2014 Duke’s choice and 11th annual JCP adopt 2013 awards, Hacker, Speaks Java,

Architect, international speaker, IoT Geek, Author.

@_tamanm

about.me/mohamedtaman

Page 4: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

WHAT IS THE PROBLEM?

Page 5: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

WE NEEDA next-generation Graphical User Interface (GUI) toolkit. As a platform that makes it easy to rapidly build high-performance Java client-side applications.

Page 6: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

WE NEEDA GUI toolkit with underlying engines take advantage of modern GPUs through hardware accelerated graphics, while providing well-designed programming interfaces, thus enabling developers to combine graphics, animation, and UI controls.

Page 7: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

INTRODUCTION

Page 8: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVA FX?JAVA + FLASH + FLEX

JAVA FX

Page 9: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVA FX?• An API included in Java SE 8

For UI development• The successor of Java Swing

Page 10: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

WHY JAVA FX?• Rich Internet Application that Cross platform:

• Windows, Mac & Linux, Solaris, Arm, Mobile.

• Familiar: 100% Java APIs with millions Library

• Easy to Develop even for Beginner

• Drag and Drop Application

• Only use Java Language Programming

• GUI Development with Cross Platform

Page 11: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

WHY JAVAFX ?

Productivity– Rapid Application Development using Tooling (Netbeans and

SceneBuilder)– Testing and…– We are coding only in Java

User Interface

Page 12: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

WHY JAVAFX ?User Interface

Capability– Layouts built using WYSIWYG– Control Set (Basic and Advanced)– Eventing (e.g. Value Change Listeners, Thread State Listeners)– CSS styling

Page 13: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

WHY JAVAFX ?FXML

VIEWS

Screen Building using Scene Builder which generates FXML

– Layout Containers– Place Controls– Associate Events– Style

Map to a Controller Class

FXML

Generates

Controller

Associate

Page 14: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVA PIONEERED RICH CLIENT APPLICATIONSBut developers had to learn multiple technologies

Page 15: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX SIMPLIFIES APPLICATION DEVELOPMENTDevelopers Focus on Capabilities Instead of Technologies

Page 16: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

LEARN THE BASIC

Page 17: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

MINIMUM STANDARD TOOLS FOR EASY DEVELOPMENT

NETBEANS, ECLIPSE, ORACLE JDeveloper JDK 7 or 8 JDK 7 -> Java FX 2.2 (Separated Installer) JDK 8 -> JAVA FX 8 Included in Installer Scene Builder 2.0 Gloun Scene Builder 8.0

Page 18: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

COMPONENT IN JAVA FX Containers

– Accordion, Anchor Pane, Stack Pane, Tab Pane, HBox, and VBox Controls

– Buttons, Choice Box, Combo Box, ImageView, WebView, TextField, TextArea, Label…

Shapes– Rectangle, Circle, Arc, Ellipse, Line, Polygon, Text, Cubic Curve

Charts – Area Chart, Bar Chart, Scatter Chart, Pie Chart, Bubble Chart

Page 19: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

SCENE BUILDER, FXML, AND CONTROLLER

Scene Builder– Drag and Drop Application for Layout GUI

FXML– Script layout GUI that generated from Scene Builder

Controller– In Order FXML be dynamic content need Controller to

control components

Page 20: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

HOW TO START?

Page 21: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

HOW TO START?

You can start with learn in Java FX Sample Demo using Ensemble8 for JDK 8.

Read my book, JavaFX essentials (Packt 2015) by Mohamed Taman.

An Amazing book, JavaFX 8: Introduction by Example, Second Edition,Carl Dea, Mark Heckler, Gerrit Grunwald, José Pereda, and Sean M. Phillips (Apress, 2014. ISBN: 978-1-4302-6460-6)

Oracle website: http://docs.oracle.com/javase/8/javase-clienttechnologies.htm

Page 22: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

DEMOS

Page 23: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX ON MOBILE

Page 24: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX ON MOBILE

Based on the official support from Oracle Corporation for JavaFX, a number of people inside the JavaFX community are working to port JavaFX to make it run on as many devices and platforms as possible (desktop, mobile, and embedded) and different operating systems, with the same codebase.

They have successfully created SDKs that allow us to develop JavaFX applications as native applications to run on Android or iOS-based devices in one bundle (JVM plus application)

Page 25: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX ON MOBILE

JavaFX applications on iOS using the port from RoboVM (http://www.robovm.org/) and on Android using the port from JavaFXPorts (http://javafxports.org/).

For interoperability with Android native API the FXActivity class, is the bridge between JavaFX and the Dalvik runtime.

Page 26: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX ON MOBILE

Now a single plugin called jfxmobile-plugin allows us to build applications for three platforms desktop, Android, and iOS from the same codebase.

Page 27: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX ON MOBILE ANDROID VERSION

Page 28: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX ON MOBILE iOS VERSION

Page 29: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX ON RASPBERRY PI

Page 30: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX ON THE RASPBERRY PI

Very closely related to the IoT world, the Raspberry Pi is a credit card-sized microcomputer designed by the Raspberry Pi Foundation for experimentation and education.

Page 31: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX ON THE RASPBERRY PI

What you should know about the Raspberry Pi is that it is nothing but a small computer. Small power requirements, small physical size, small memory, and most importantly a low-cost device.

Everything about it is small, but it is still just a computer and it uses Linux.

Page 32: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX ON THE RASPBERRY PI

Java was made for IoT from the first day of its invention.

Java was created with a clear vision in mind: to control small devices such as television set-top boxes.

With the explosion of IoT, Java returns to its roots.

Page 33: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX ON THE RASPBERRY PI

You may think that JavaFX, a platform for rich-client development, would miss the IoT party—but it is not so! According to the JavaFX Overview page on the Oracle Technology Network:

– "It is designed to provide a lightweight, hardware-accelerated Java UI platform"

This statement holds the key to graphically rich-and-powerful JavaFX: hardware acceleration and; luckily, the Raspberry Pi comes with a powerful GPU.

Page 34: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX ON THE RASPBERRY PI

Page 35: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX ON THE RASPBERRY PI

Page 36: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX WITH ARDUINO

Page 37: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX WITH ARDUINO

Arduino is an open source electronics tool based on a simple programmable microcontroller board that can be programmed using a free open source IDE.

Page 38: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX WITH ARDUINO

Alone or attached to a computer, it creates interactive devices that can sense by taking inputs from a variety of switches or sensors and can act by controlling a variety of lights, motors, and other outputs physical devices.

Page 39: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX WITH ARDUINO

Arduino runs standalone or can communicate with software running on your computer (Java, JavaFX, Python, and so on) and the boards can be assembled by hand or purchased preassembled.

Page 40: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX WITH ARDUINO (DEMO)

A desktop application using JavaFX along with an Arduino board in order to monitor data coming from a real world temperature sensor and report it on a chart,

How HOT blooded you really are!

Page 41: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX WITH ARDUINO (DEMO)

Page 42: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX WITH ARDUINO (DEMO)

Page 43: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

JAVAFX WITH ARDUINO (THREADING)

The main use of Platform.runLater() is placing the task of filling the series data with the incoming Arduino input in the JavaFX thread.

Also it gives the required time to the Scene graph to render the chart, skipping values if they are added too fast.

Page 44: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

TOUCHLESS JAVAFX APPS

Page 45: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

TOUCHLESS JAVAFX APPS

Every day we notice the rise of input interfaces that are less mouse-centric and more in favor of touchless input.

Gestures are one of the ways humans can communicate with machines naturally these days.

Page 46: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

TOUCHLESS JAVAFX APPS

There are several devices on the market that actually allow us to interact with computers using just some parts of our body: many games for the Xbox, the Microsoft game console, use the Kinect controller to recognize the user's body movements.

The myoelectric armband detects movements in your muscles and translates them into gestures so that you can interact with your computer.

Leap Motion controller recognizes users' hands and fingers and translate the movements and gestures to the computer.

Page 47: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

TOUCHLESS JAVAFX APPS (LEAP MOTION)

Here is a very tiny device with 13 mm height, 30 mm width, 76 mm depth, and a weight of 45 grams (final dimensions: 0.5" x 1.2" x 3").

With the Leap Motion software running on your computer, just plug the controller into the USB on your Mac or PC and you are ready to go (without any external power source).

Page 48: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

TOUCHLESS JAVAFX APPS (DEMO 3D)

Page 49: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

RESOURCES JavaFX website: http://javafx.com Open source project

http://openjdk.java.net/projects/openjfx/ Oracle Premier Support for Software

http://www.oracle.com/us/support/software/premier/ Blogs

– http://fxexperience.com– http://blogs.oracle.com/javafx

Book, JavaFX essentials 2015 by Mohamed Taman. Oracle website: http://docs.oracle.com/javase/8/javase-clienttechnologies.htm

Page 50: JavaFX 8 everywhere; write once run anywhere by Mohamed Taman

THANK YOU