SlideShare a Scribd company logo
Introduction of JavaFx
Prem Chand Mali
About Me
SCJP/OCJP - Oracle Certified Java Programmer
MCP:70-480 - Specialist certification in HTML5
with JavaScript and CSS3 Exam
Skills : Java, Swings, Springs,
Hibernate, JavaFX, Jquery,
prototypeJS, ExtJS.
Connect Me :
Facebook : https://www.facebook.com/prem.c.mali
LinkedIn: http://www.linkedin.com/in/premmali
Twitter: https://twitter.com/prem_mali
Google+ : https://plus.google.com/106150245941317924019/about/p/pub
Contact Me :
Email : premchandm@mindfiresolutions.com / prem.c.mali@gmail.com
Skype: mfsi_premchandm
Agenda


Event Handling.



Property and Bindings



WebView and MediaPlayer



Shapes



Bind event on shapes



Q&A
Event Handling


What is an event ?



Event types



Event targets



Event delivery process
What is an event ?
Event is occurrence which happens in application with or
without participation of human.


JavaFx events are instance of javafx.event.Event or
subclass of Event.




Event has following three properties.
– Event type : Type of event
– Source : Origin of the event, source changes as the
event is passed along the chain.
Target: No on which the action occurred
Event Type


An event type is an instance of the EventType class.
Event.Any

WindowEvent.Any

ActionEvent.Action

InputEvent.Any

WindowEvent.Showing

KeyEvent.Any

WindowEvent.Shown

KeyEvent.Key_Pressed

MouseEvent.Mouse_Presse
d

KeyEvent.Key_Release
d

MouseEvent.Mouse_Released

KeyEvent.Any

MouseEvent.Any

...
Event Target
• Target can be instance of any class that implements
EventTarget interface.
• Implementation of buildEventDispatchChain creates the
event dispatch chain that the event must travel to reach
target.
• Window, scene, node classes implement the EventTarget
interface and subclasses of those classes inherit the
implementation.
• If custom control is not subclass from Window, Scene, or
Node then you need to implement EventTarget.
Event delivery process
• Event delivery process contains following four steps
– Target Selection
– Route construction
– Event capturing
– Event bublling
Properties and Binding
• JavaBeans component architecture to represent the
property of an object. JavaFx expended and improved it.
• JavaFX properties are often used in conjunction with
binding, a powerful mechanism for expressing direct
relationships between variables.
• Properties classes is part of javafx.beans.property
package.
• A binding observes its list of dependencies for changes,
and then updates itself automatically after a change has
been detected. It is following two types of API
– High Level
– Low Level
Properties and Binding


Fluent API

IntegerProperty num1 = new SimpleIntegerProperty(1);
IntegerProperty num2 = new SimpleIntegerProperty(2);
NumberBinding sum = num1.add(num2);
System.out.println(sum.getValue());
num1.set(2);
System.out.println(sum.getValue());


Binding class

NumberBinding sum = Bindings.add(num1,num2);



Both Approach

Bindings.add(num1.multiply(num2),num3.multiply(num4));
Properties and Buinding


Low Level API example

DoubleBinding db = new DoubleBinding() {
{
super.bind(a, b, c, d);
}
@Override
protected double computeValue() {
return (a.get() * b.get()) + (c.get() * d.get());
}
};
WebView
The WebView component is based on WebKit, an open
source web browser engine. It supports Cascading Style
Sheets (CSS), JavaScript, Document Object Model (DOM),
and HTML5.


It enables you to perform following tasks.
–
–
–
–
–
–

Render HTML content from local and remote URLs
Obtain Web history
Execute JavaScript commands
Perform upcalls from JavaScript to JavaFX
Manage web pop-up windows
Apply effects to the embedded browser
Media
The javafx.scene.media package enables developers to
create media applications that provide media playback in
the desktop window or within a web page on supported
platforms.


Currently supported formats.
– Audio: MP3; AIFF containing uncompressed PCM;
WAV containing uncompressed PCM; MPEG-4
multimedia container with Advanced Audio Coding
(AAC) audio
– Video: FLV containing VP6 video and MP3 audio;
MPEG-4 multimedia container with H.264/AVC
(Advanced Video Coding) video compression.
Media
Some of the features supported by the JavaFX media
stack include the following


–
–
–
–
–
–
–
–



FLV container with MP3 and VP6
MP3 audio
MPEG-4 container with either AAC, H.264, or both
HTTP, FILE protocol support
Progressive download
Seeking
Buffer progress
Playback functions (Play, Pause, Stop, Volume,
Mute, Balance, Equalizer)

Media components
– Media – A media resource, containing information
about the media, such as its source, resolution, and
metadata.
– MediaPlayer – The key component providing the
controls for playing media.
Media
Media components
– MediaView – A Node object to support animation,
translucency, and effects
Shapes
• JavaFx also provided capability to draw following shapes
on scene.
– Circle
– Rectangle
– Ellipse
– Line
– Polygon
– etc
Events on Shapes
• JavaFx Shape API also provide capability to add event on
Shapes.
For example :
rect.setOnMouseClicked(new
EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
Color color = (((Color)
rect.getFill()).equals(Color.RED))
? Color.BROWN : Color.RED;
rect.setFill(color);
}
});
Q&A

More Related Content

PPTX
Java fx
ODP
JavaFX in Action Part I
PDF
002- JavaFX Tutorial - Getting Started
PPTX
Struts & hibernate ppt
PPT
Java for Recruiters
PDF
The Brainify App - JavaFx
PPTX
Groovy features
PDF
Common Client Rich Client Platforms
Java fx
JavaFX in Action Part I
002- JavaFX Tutorial - Getting Started
Struts & hibernate ppt
Java for Recruiters
The Brainify App - JavaFx
Groovy features
Common Client Rich Client Platforms

What's hot (20)

PDF
MV(C, mvvm) in iOS and ReactiveCocoa
PPTX
JAVA Training Syllabus Course
PPT
Spring ppt
PPTX
Lecture java basics
PPTX
J2EE Struts with Hibernate Framework
PPSX
CR Bridge Solutions Pvt Ltd. Java slides
PPTX
Java Programming
PPTX
PPTX
Spring presentation
PDF
Overview of React.JS - Internship Presentation - Week 5
PPT
Java introduction
PDF
Ad103 - Have it Your Way: Extending IBM Lotus Domino Designer
PDF
Introduction to java technology
PDF
Core java course syllabus
PPTX
Java programming course for beginners
PPT
Chapter 1 introduction to java technology
PPTX
Java seminar
PPTX
Features of java
PPT
Netbeans IDE & Platform
PDF
Java basics notes
MV(C, mvvm) in iOS and ReactiveCocoa
JAVA Training Syllabus Course
Spring ppt
Lecture java basics
J2EE Struts with Hibernate Framework
CR Bridge Solutions Pvt Ltd. Java slides
Java Programming
Spring presentation
Overview of React.JS - Internship Presentation - Week 5
Java introduction
Ad103 - Have it Your Way: Extending IBM Lotus Domino Designer
Introduction to java technology
Core java course syllabus
Java programming course for beginners
Chapter 1 introduction to java technology
Java seminar
Features of java
Netbeans IDE & Platform
Java basics notes
Ad

Similar to Java FX Part2 (20)

PDF
CS3391 -OOP -UNIT – V NOTES FINAL.pdf
PDF
Introduction to JavaFX
PDF
Demo on JavaFX
PDF
Domain Driven Design
PDF
JavaFXaeurwstkiryikryiuyoyiloyuikygi.pdf
PDF
UNIT 5-JavaFX Event Handling, Controls and Components.pdf
PPTX
JavaFX ALA ppt.pptx
PPTX
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
PPTX
JavaFX Presentation
PDF
Javafxpressentation 140524053934-phpapp01 (1)
PDF
JavaFX for Java Developers
PDF
Java Fx Ajaxworld Rags V1
PDF
JavaFX 2 Rich Desktop Platform
PPTX
Complete Solution for JavaFX Development - NexSoftSys
PDF
JavaFx Introduction, Basic JavaFx Architecture
PDF
JavaOne - The JavaFX Community and Ecosystem
PPT
JavaFX - Next Generation Java UI
PPT
What is java fx?
PPTX
Untitled (1)-------------------------------------------------.pptx
PPTX
Java AWT and Java FX
CS3391 -OOP -UNIT – V NOTES FINAL.pdf
Introduction to JavaFX
Demo on JavaFX
Domain Driven Design
JavaFXaeurwstkiryikryiuyoyiloyuikygi.pdf
UNIT 5-JavaFX Event Handling, Controls and Components.pdf
JavaFX ALA ppt.pptx
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
JavaFX Presentation
Javafxpressentation 140524053934-phpapp01 (1)
JavaFX for Java Developers
Java Fx Ajaxworld Rags V1
JavaFX 2 Rich Desktop Platform
Complete Solution for JavaFX Development - NexSoftSys
JavaFx Introduction, Basic JavaFx Architecture
JavaOne - The JavaFX Community and Ecosystem
JavaFX - Next Generation Java UI
What is java fx?
Untitled (1)-------------------------------------------------.pptx
Java AWT and Java FX
Ad

More from Mindfire Solutions (20)

PDF
Physician Search and Review
PDF
diet management app
PDF
Business Technology Solution
PDF
Remote Health Monitoring
PDF
Influencer Marketing Solution
PPT
High Availability of Azure Applications
PPTX
IOT Hands On
PPTX
Glimpse of Loops Vs Set
ODP
Oracle Sql Developer-Getting Started
PPT
Adaptive Layout In iOS 8
PPT
Introduction to Auto-layout : iOS/Mac
PPT
LINQPad - utility Tool
PPT
Get started with watch kit development
PPTX
Swift vs Objective-C
ODP
Material Design in Android
ODP
Introduction to OData
PPT
Ext js Part 2- MVC
PPT
ExtJs Basic Part-1
PPT
Spring Security Introduction
Physician Search and Review
diet management app
Business Technology Solution
Remote Health Monitoring
Influencer Marketing Solution
High Availability of Azure Applications
IOT Hands On
Glimpse of Loops Vs Set
Oracle Sql Developer-Getting Started
Adaptive Layout In iOS 8
Introduction to Auto-layout : iOS/Mac
LINQPad - utility Tool
Get started with watch kit development
Swift vs Objective-C
Material Design in Android
Introduction to OData
Ext js Part 2- MVC
ExtJs Basic Part-1
Spring Security Introduction

Recently uploaded (20)

PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Cloud computing and distributed systems.
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Machine learning based COVID-19 study performance prediction
PDF
Electronic commerce courselecture one. Pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Approach and Philosophy of On baking technology
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Empathic Computing: Creating Shared Understanding
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
“AI and Expert System Decision Support & Business Intelligence Systems”
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Review of recent advances in non-invasive hemoglobin estimation
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Cloud computing and distributed systems.
Unlocking AI with Model Context Protocol (MCP)
Machine learning based COVID-19 study performance prediction
Electronic commerce courselecture one. Pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Per capita expenditure prediction using model stacking based on satellite ima...
Approach and Philosophy of On baking technology
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Empathic Computing: Creating Shared Understanding
Building Integrated photovoltaic BIPV_UPV.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
20250228 LYD VKU AI Blended-Learning.pptx

Java FX Part2

  • 2. About Me SCJP/OCJP - Oracle Certified Java Programmer MCP:70-480 - Specialist certification in HTML5 with JavaScript and CSS3 Exam Skills : Java, Swings, Springs, Hibernate, JavaFX, Jquery, prototypeJS, ExtJS. Connect Me : Facebook : https://www.facebook.com/prem.c.mali LinkedIn: http://www.linkedin.com/in/premmali Twitter: https://twitter.com/prem_mali Google+ : https://plus.google.com/106150245941317924019/about/p/pub Contact Me : Email : premchandm@mindfiresolutions.com / prem.c.mali@gmail.com Skype: mfsi_premchandm
  • 3. Agenda  Event Handling.  Property and Bindings  WebView and MediaPlayer  Shapes  Bind event on shapes  Q&A
  • 4. Event Handling  What is an event ?  Event types  Event targets  Event delivery process
  • 5. What is an event ? Event is occurrence which happens in application with or without participation of human.  JavaFx events are instance of javafx.event.Event or subclass of Event.   Event has following three properties. – Event type : Type of event – Source : Origin of the event, source changes as the event is passed along the chain. Target: No on which the action occurred
  • 6. Event Type  An event type is an instance of the EventType class. Event.Any WindowEvent.Any ActionEvent.Action InputEvent.Any WindowEvent.Showing KeyEvent.Any WindowEvent.Shown KeyEvent.Key_Pressed MouseEvent.Mouse_Presse d KeyEvent.Key_Release d MouseEvent.Mouse_Released KeyEvent.Any MouseEvent.Any ...
  • 7. Event Target • Target can be instance of any class that implements EventTarget interface. • Implementation of buildEventDispatchChain creates the event dispatch chain that the event must travel to reach target. • Window, scene, node classes implement the EventTarget interface and subclasses of those classes inherit the implementation. • If custom control is not subclass from Window, Scene, or Node then you need to implement EventTarget.
  • 8. Event delivery process • Event delivery process contains following four steps – Target Selection – Route construction – Event capturing – Event bublling
  • 9. Properties and Binding • JavaBeans component architecture to represent the property of an object. JavaFx expended and improved it. • JavaFX properties are often used in conjunction with binding, a powerful mechanism for expressing direct relationships between variables. • Properties classes is part of javafx.beans.property package. • A binding observes its list of dependencies for changes, and then updates itself automatically after a change has been detected. It is following two types of API – High Level – Low Level
  • 10. Properties and Binding  Fluent API IntegerProperty num1 = new SimpleIntegerProperty(1); IntegerProperty num2 = new SimpleIntegerProperty(2); NumberBinding sum = num1.add(num2); System.out.println(sum.getValue()); num1.set(2); System.out.println(sum.getValue());  Binding class NumberBinding sum = Bindings.add(num1,num2);  Both Approach Bindings.add(num1.multiply(num2),num3.multiply(num4));
  • 11. Properties and Buinding  Low Level API example DoubleBinding db = new DoubleBinding() { { super.bind(a, b, c, d); } @Override protected double computeValue() { return (a.get() * b.get()) + (c.get() * d.get()); } };
  • 12. WebView The WebView component is based on WebKit, an open source web browser engine. It supports Cascading Style Sheets (CSS), JavaScript, Document Object Model (DOM), and HTML5.  It enables you to perform following tasks. – – – – – – Render HTML content from local and remote URLs Obtain Web history Execute JavaScript commands Perform upcalls from JavaScript to JavaFX Manage web pop-up windows Apply effects to the embedded browser
  • 13. Media The javafx.scene.media package enables developers to create media applications that provide media playback in the desktop window or within a web page on supported platforms.  Currently supported formats. – Audio: MP3; AIFF containing uncompressed PCM; WAV containing uncompressed PCM; MPEG-4 multimedia container with Advanced Audio Coding (AAC) audio – Video: FLV containing VP6 video and MP3 audio; MPEG-4 multimedia container with H.264/AVC (Advanced Video Coding) video compression.
  • 14. Media Some of the features supported by the JavaFX media stack include the following  – – – – – – – –  FLV container with MP3 and VP6 MP3 audio MPEG-4 container with either AAC, H.264, or both HTTP, FILE protocol support Progressive download Seeking Buffer progress Playback functions (Play, Pause, Stop, Volume, Mute, Balance, Equalizer) Media components – Media – A media resource, containing information about the media, such as its source, resolution, and metadata. – MediaPlayer – The key component providing the controls for playing media.
  • 15. Media Media components – MediaView – A Node object to support animation, translucency, and effects
  • 16. Shapes • JavaFx also provided capability to draw following shapes on scene. – Circle – Rectangle – Ellipse – Line – Polygon – etc
  • 17. Events on Shapes • JavaFx Shape API also provide capability to add event on Shapes. For example : rect.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { Color color = (((Color) rect.getFill()).equals(Color.RED)) ? Color.BROWN : Color.RED; rect.setFill(color); } });
  • 18. Q&A