SlideShare a Scribd company logo
Introduction to
JavaFX 2
Thierry Wasylczenko
@twasyl
me.getInfo();
Software & quality engineer @ GE Healthcare
JFXtras contributor
OpenJFX in progress
Former Java Full Professor & teacher @ SUPINFO
Speaker
Desktop apps in Java
Abstract Window Toolkit (AWT)
Swing
Event Dispatch Thread (EDT)
Complex
L&F
Old looking
Nimbus
Synthetica, JGoodies Looks, SWT Ribbon, Quaqua, Substance, ...
The big button syndrome
Some tools "helped" us ...
Visual Editor
Eclipse plugin
How many JARs do I need to start creating a UI??!!
NetBeans
... or not !

So much junk code !!
Not even editable
Except outside the IDE
A hope shined ...
JavaOne 2007
JavaFX is announced
Rich Internet Applications (RIA)
"Seems" promising
... but ...
Java + Flash + Flex
=
JavaFX
=
???
I am a Java developer !!
Scripting language
Similar to Flash scripting language
Unusable Java API
JARs? What's that?
Hey, I'm a Java developer !!
Look through the Windows
Windows Presentation Foundation (WPF)
Works above DirectX
Introduced with .NET 3.0
XAML
Hey, I'm still a Java developer !
eface
And now ...
JavaFX 2

EOL of JavaFX 1.2 & 1.3
December, 20th 2012
JavaFX architecture
Base classes
Application
The entry point of your app
Application.launch()
Override start()
Scene
Like the content pane in Swing
Hosts a root element
Stage = JFrame
Contains a scene
stage.show();
Base classes
pbi casTetalXetnsApiain{
ulc ls weWlF xed plcto
pbi sai vi mi(tig]ag){
ulc ttc od anSrn[ rs
Apiainluc(weWlF.ls,ag)
plcto.anhTetalXcas rs;
}
@vrie
Oerd
pbi vi satSaesae trw Ecpin{
ulc od tr(tg tg) hos xeto
/ D yu sufhr
/ o or tf ee
Seesee=nwSee ..)
cn cn
e cn( . ;
saestcn(cn)
tg.eSeesee;
saeso(;
tg.hw)
}
}
FXML

V

M
C
Markup­based language
CSS styling
JavaScript capabilities
Component binding
Controller concept
URL locator
I18N
FXML
<xlvrin"."ecdn=UF8?
?m eso=10 noig"T-">
<ipr jv.ag*>
?mot aaln.?
<ipr jvf.cn.?
?mot aaxsee*>
<ipr jvf.cn.fet*>
?mot aaxseeefc.?
<ipr jvf.cn.mg.?
?mot aaxseeiae*>
<ipr jvf.cn.oto.?
?mot aaxseecnrl*>
<ipr jvf.cn.aot*>
?mot aaxseelyu.?
<nhraexlsf=ht:/aaxcmfm"i=miPnl f:d"nhrae peHih=78 peWdh
AcoPn mn:x"tp/jvf.o/xl d"anae" xi=acoPn" rfegt"6" rfit=
"04 f:otolr"o.wsltetalxcnrlesTetalXotolr
12" xcnrle=cmtay.wewlf.otolr.weWlFCnrle"
sye"f-akrudclr lna-rdet#9440,#00910)">
tl=-xbcgon-oo: iergain(6BE % 07B 0%;
<hlrn
cide>
<mgVe i=titrtce"ftit=18 ftegt"2"lyuX"0 lyuY"0>
Iaeiw d"wteSikr iWdh"2" iHih=18 aot=3" aot=3"
<mg>
iae
<mg ul"/o/wsltetalxrsucsiae/wteSikrpg /
Iae r=@cmtay/wewlf/eore/mgstitrtce.n" >
<iae
/mg>
<Iaeiw
/mgVe>
<ae tx=TetalX peWdh"04 sye"f-otsz:10t -xtx-il wie -xf
Lbl et"weWlF" rfit=12" tl=-xfn-ie 0p; f-etfl: ht; fotwih:bl; lyuY"0 /
n-egt od" aot=3" >
<utni=bto"tx=Sac"oAto=#trTetal sye"f-otsz:2p; /
Bto d"utn et"erh ncin"satweWl" tl=-xfn-ie 0t" >
<cide>
/hlrn
<AcoPn>
/nhrae
JavaFX CSS
Properties prefixed with ­fx
­fx­text­fill
­fx­background­color
...
linear­gradient
radial­gradient
rgb / rgba
Effects
dropshadow & innershadow
JavaFX CSS
Inline CSS
<ae tx=TetalX peWdh"04 sye"f-otsz:10t -xtx-il wie -xfn-eg
Lbl et"weWlF" rfit=12" tl=-xfn-ie 0p; f-etfl: ht; f-otwi
h:bl; lyuY"0 /
t od" aot=3" >
JavaFX CSS
Stylesheets and CSS classes
<nhrae..
AcoPn .>
<tlset>
syehes
<R vle"/o/wslDfutcs /
UL au=@cmtay/eal.s" >
<syehes
/tlset>
<hlrn
cide>
<ae syels=co-ls"/
Lbl tlCas"olcas >
<ae>
Lbl
<tlCas
syels>
<tigf:au=vr-olcas /
Srn xvle"eyco-ls" >
<tigf:au=aaigcas /
Srn xvle"mzn-ls" >
<syels>
/tlCas
<Lbl
/ae>
<hlrn
cide>
<AcoPn>
/nhrae
JavaFX CSS
Java code
mBto.eSyels(.dAl"olcas,"eyco-ls";
yutngttlCas)adl(co-ls" vr-olcas)
mBto.eSye"f-akrudclr wie)
yutnsttl(-xbcgon-oo: ht";
Controller
Similar to master pages in ASP
Similar to a Managed Bean
Used to
manage events
update the view dynamically
...
Referenced by fx:controller in the FXML
Initializable
Used to initialize the controller after the root element
Controller
pbi casTetalXotolripeet Iiilzbe{
ulc ls weWlFCnrle mlmns ntaial
/ ..
/ .
@vrie
Oerd
pbi vi iiilz(R ag,RsucBnl ag){
ulc od ntaieUL r0 eoreude r1
/ ..
/ .
}
}
@FXML
Component binding
Like JSF
Each attribute must be strictly named as the fx:id in the FXML
Controller Method Event handler
onAction, onClosed, ... attributes
Referenced with # in FXML
@FXML
The controller
/ ..
/ .
@XLpiaePn acoPn;
FM rvt ae nhrae
@XLpbi vi satweWl(cinvn e {
FM ulc od trTetalAtoEet )
/ ..
/ .
}
/ ..
/ .
@FXML
The FXML
<nhrae..f:d"nhrae ..f:otolr"o.wsltetalxcnrlesTetalXoto
AcoPn . xi=acoPn" . xcnrle=cmtay.wewlf.otolr.weWlFCnrl
lr ..>
e" .
<hlrn
cide>
<utni=bto"oAto=#trTetal ../
Bto d"utn ncin"satweWl" . >
<cide>
/hlrn
<AcoPn>
/nhrae
FXMLLoader
Load a FXML file
ResourceBundle can be defined
Get the controller
FXMLLoader
ULfmUL=gtls(.eRsuc(/ypcaemFl.xl)
R xlR
eCas)gteore"m/akg/yiefm";
FMLae fm =nwFMLae(xlR)
XLodr xl
e XLodrfmUL;
/ Gttero eeeto tefl
/ e h ot lmn f h ie
Prn ro =(aet fm.od)
aet ot
Prn) xlla(;
/ Gttecnrle ascae t teFM
/ e h otolr soitd o h XL
MCnrle m =(yotolr fm.eCnrle(;
yotolr c
MCnrle) xlgtotolr)
Properties
Expand & improve the JavaBeans concept
"Observe" a value
Event delivery
Listeners
Convention
private property fields
public final getter / setter for the value
public getter for the property
Properties
pbi casFo{
ulc ls o
piaeDulPoet ltrOCfe =nwSmlDulPoet(;
rvt oberpry iesfofe
e ipeoberpry)
pbi fnldul gtiesfofe){
ulc ia obe eLtrOCfe(
rtr ti.iesfofegt)
eun hsltrOCfe.e(;
}
pbi fnlvi stiesfofedul vle {
ulc ia od eLtrOCfe(obe au)
ti.iesfofestvle;
hsltrOCfe.e(au)
}
pbi DulPoet ltrOCfePoet( {
ulc oberpry iesfoferpry)
rtr ti.iesfofe
eun hsltrOCfe;
}
}
Bindings
Observes dependencies
Properties
Updates itself according changes
High­Level API
Low­Level API
Kind of Observer / Observable pattern
Example:
Could be used to synchronize the UI and the business
Refresh a chart data
Bindings
Itgrrprynm =nwSmlItgrrpry1)
neePoet u1
e ipeneePoet(0;
Itgrrprynm =nwSmlItgrrpry2)
neePoet u2
e ipeneePoet(0;
Itgrrprynm =nwSmlItgrrpry3)
neePoet u3
e ipeneePoet(0;
Itgrrprynm =nwSmlItgrrpry4)
neePoet u4
e ipeneePoet(0;
NmeBnigoeain=Bnig.d(u1mlil(u4,nm.iienm);
ubridn prto
idnsadnm.utpynm) u2dvd(u3)
Sse.u.rnl(Hwmc?"+oeaingtau()
ytmotpitn"o uh
prto.eVle);
nm.eVle10;
u1stau(0)
Sse.u.rnl(Adnw "+oeaingtau()
ytmotpitn"n o?
prto.eVle);
Bindings
How much? 400.67
And now? 4000.67
Bindings
FXCollections
Extension of Collections
Observable
Interfaces
ObservableList, ObservableMap
Listeners
ListChangeListener, MapChangeListener
FXCollections
Utility class
FXCollections
Ls<tig srnLt=nwAryitSrn>)
itSrn> tigs
e raLs<tig(;
/ Cet a osral ls
/ rae n bevbe it
OsralLs<tig srnOss1=FCletososralLs(tigs)
bevbeitSrn> tigbLt
Xolcin.bevbeitsrnLt;
OsralLs<tig srnOss2=FCletososralLs(;
bevbeitSrn> tigbLt
Xolcin.bevbeit)
srnOss1aditnrnwLsCagLsee<tig( {
tigbLt.dLsee(e ithneitnrSrn>)
@vrie
Oerd
pbi vi oCagdCag< etnsSrn>eet {
ulc od nhne(hne? xed tig vn)
wieeetnx(){
hl(vn.et)
i(vn.aAdd) {
feetwsde()
/ ..
/ .
}es i(vn.aRmvd) {
le feetwseoe()
/ ..
/ .
}
}
}
}
Chart API
Chart API
Animation
Animation
KeyValue
Represent a "fixed" position of a Node
KeyFrame
A duration
Some KeyValues
Animation
Could contain some KeyFrames (Timeline)
Play
Animation
Nd nd =..;
oe oe
.
Kyau k =nwKyau(oelyuXrpry) 10;
eVle v
e eVlend.aotPoet(, 0)
Kyrm k =nwKyrm(e Drto(00,k)
eFae f
e eFaenw uain50) v;
Tmln tmln =nwTmln(f;
ieie ieie
e ieiek)
tmln.eCceon(nmto.NEIIE;
ieiestylCutAiainIDFNT)
tmln.eOFnse(..)
ieiestniihd . ;
tmln.ly)
ieiepa(;
Effects
Lot of effects available
Blur, blend, reflection, shadows, ...
Input property
Chain of effects
Media

Long way from JMF
Audio
MP3, AIFF, WAV, AAC, m4a
Video
FLV, MPEG­4 (H.264/AVC)
Metadata
Listeners
Media
Fl mSn =nwFl(/yogm3)
ie yog
e ie"mSn.p";
MdamMda=nwMdamSn.oR(.otig);
ei yei
e ei(yogtUI)tSrn()
Mdalyrpae =nwMdalyrmMda;
eiPae lyr
e eiPae(yei)
pae.eOEdfei(nwRnal( {..};
lyrstnnOMda e unbe)
. )
pae.ouerpry)aditnr ..)
lyrvlmPoet(.dLsee( . ;
pae.ly)
lyrpa(;
/ ..
/ .
i(lyrsauPoet(.e( = Sau.LYN){
fpae.ttsrpry)gt) = ttsPAIG
/ ..
/ .
}
SceneBuilder
UI builder tool
Useful for RAD
FXML generation
CSS support
Previewer
SceneBuilder
Scenic View
Understand current state of your application
Manipulation of the scenegraph
Manipulation of properties
Scenic View
Tools / API
JFXtras
FX Experience tool
Theming
e(fx)clipse
GroovyFX
ScalaFX
...
Useful resources
http://thierrywasyl.wordpress.com
http://docs.oracle.com/javafx/index.html
https://forums.oracle.com/forums/forum.jspa?forumID=1385
http://fxexperience.com
http://jfxtras.org
Thank you

More Related Content

PDF
JavaFX, because you're worth it
PDF
Flow of events during Media Player creation in Android
PDF
The State of PHPUnit
PDF
Pdr ppt
PDF
The State of PHPUnit
PDF
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
PDF
Javascript fundamentals for php developers
PDF
Non stop random2b
JavaFX, because you're worth it
Flow of events during Media Player creation in Android
The State of PHPUnit
Pdr ppt
The State of PHPUnit
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
Javascript fundamentals for php developers
Non stop random2b

What's hot (20)

PDF
Ff to-fp
PDF
穏やかにファイルを削除する
PDF
Drupal 8 in action, the route to the method
PPTX
Build a compiler in 2hrs - NCrafts Paris 2015
PDF
Refactoring to symfony components
PDF
The Ring programming language version 1.10 book - Part 92 of 212
PDF
[Webinar] An Hour with the CTO: All About APIs and the Nuxeo Platform
PDF
OSDC.TW - Gutscript for PHP haters
PPTX
How to recognise that the user has just uninstalled your android app
PPTX
How to recognise that the user has just uninstalled your android app droidc...
PDF
Javascript: The Important Bits
PDF
Android Multimedia Framework
PDF
Введение в REST API
PDF
Try Redis - interactive Tutorial
PDF
Debugging: Rules And Tools - PHPTek 11 Version
PDF
Teaching Your Machine To Find Fraudsters
PDF
Mobile conf erich
PDF
Grammatical Optimization
PDF
Building modern web apps with html5, javascript, and java
PDF
The Browser Environment - A Systems Programmer's Perspective
Ff to-fp
穏やかにファイルを削除する
Drupal 8 in action, the route to the method
Build a compiler in 2hrs - NCrafts Paris 2015
Refactoring to symfony components
The Ring programming language version 1.10 book - Part 92 of 212
[Webinar] An Hour with the CTO: All About APIs and the Nuxeo Platform
OSDC.TW - Gutscript for PHP haters
How to recognise that the user has just uninstalled your android app
How to recognise that the user has just uninstalled your android app droidc...
Javascript: The Important Bits
Android Multimedia Framework
Введение в REST API
Try Redis - interactive Tutorial
Debugging: Rules And Tools - PHPTek 11 Version
Teaching Your Machine To Find Fraudsters
Mobile conf erich
Grammatical Optimization
Building modern web apps with html5, javascript, and java
The Browser Environment - A Systems Programmer's Perspective
Ad

Similar to Introduction to JavaFX 2 (20)

PDF
SecureSocial - Authentication for Play Framework
PDF
Building android apps with kotlin
PPT
Introduction To JSFL
PPTX
Category theory, Monads, and Duality in the world of (BIG) Data
PDF
Netty: asynchronous data transfer
PPT
Epoll - from the kernel side
PPT
Daejeon IT Developer Conference Web Service Practice
PDF
What`s new in Java 7
ODP
Clustering Made Easier: Using Terracotta with Hibernate and/or EHCache
PDF
Geospatial ETL with Stetl - GeoPython 2016
PDF
Minicurso Android
KEY
Paris js extensions
PPTX
Don't Be Afraid of Abstract Syntax Trees
PDF
Creating windows store java script apps
PDF
Androidの本当にあった怖い話
PDF
Hazelcast - In-Memory DataGrid
PDF
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
PDF
Slides Aquarium Paris 2008
PDF
Beginner workshop to angularjs presentation at Google
PDF
Introduction to AngularJS
SecureSocial - Authentication for Play Framework
Building android apps with kotlin
Introduction To JSFL
Category theory, Monads, and Duality in the world of (BIG) Data
Netty: asynchronous data transfer
Epoll - from the kernel side
Daejeon IT Developer Conference Web Service Practice
What`s new in Java 7
Clustering Made Easier: Using Terracotta with Hibernate and/or EHCache
Geospatial ETL with Stetl - GeoPython 2016
Minicurso Android
Paris js extensions
Don't Be Afraid of Abstract Syntax Trees
Creating windows store java script apps
Androidの本当にあった怖い話
Hazelcast - In-Memory DataGrid
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
Slides Aquarium Paris 2008
Beginner workshop to angularjs presentation at Google
Introduction to AngularJS
Ad

More from Thierry Wasylczenko (7)

PDF
Du développement à la livraison avec JavaFX et le JDK9
PDF
JavaFX et le JDK9
PDF
#JavaFX.forReal() - ElsassJUG
PDF
#JavaFX.forReal()
PDF
Construire une application JavaFX 8 avec gradle
PDF
#Polyglottisme, une autre manière de développer une application
PDF
Java goes wild, lesson 1
Du développement à la livraison avec JavaFX et le JDK9
JavaFX et le JDK9
#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal()
Construire une application JavaFX 8 avec gradle
#Polyglottisme, une autre manière de développer une application
Java goes wild, lesson 1

Recently uploaded (20)

PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Tartificialntelligence_presentation.pptx
PPTX
Spectroscopy.pptx food analysis technology
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Programs and apps: productivity, graphics, security and other tools
Network Security Unit 5.pdf for BCA BBA.
Digital-Transformation-Roadmap-for-Companies.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Building Integrated photovoltaic BIPV_UPV.pdf
cuic standard and advanced reporting.pdf
Spectral efficient network and resource selection model in 5G networks
Encapsulation_ Review paper, used for researhc scholars
Unlocking AI with Model Context Protocol (MCP)
The Rise and Fall of 3GPP – Time for a Sabbatical?
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
NewMind AI Weekly Chronicles - August'25-Week II
SOPHOS-XG Firewall Administrator PPT.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Tartificialntelligence_presentation.pptx
Spectroscopy.pptx food analysis technology

Introduction to JavaFX 2