Table of Contents....4
About the Authors....13
About the Technical Reviewer....14
Contributors....15
Chapter 1: Getting Started with Client Java....16
Java Client Technology in Action....16
Java Clients in Business....17
Gaming and 3D....18
Mobile Conference Apps....20
A Modern Approach to Client Java....22
Target Mobile First....22
Build for the Cloud....24
Package Your Platform....26
Setting Up Your Environment....27
macOS JDK Installation....28
Windows JDK Installation....29
Linux JDK Installation....33
JavaFX Installation....33
Your First Modern Java Client....35
Coding Client Apps with IntelliJ IDEA....35
Rapid Application Development with Scene Builder....40
The Path to Modern Client Development....47
Chapter 2: JavaFX Fundamentals....48
JavaFX Stage and Scene Graph....48
JavaFX Is Single-Threaded....49
Hierarchical Node Structure....49
A Simple Shape Example....51
Color....53
Text Is a Shape....54
The JavaFX Coordinate System....54
Layout Controls....55
StackPane....55
AnchorPane....56
GridPane....56
FlowPane and TilePane....57
BorderPane....57
SplitPane....58
HBox, VBox, and ButtonBar....58
Make a Scene....58
Enhancing the MyShapes Application....59
Linear Gradient....59
DropShadow....60
Reflection....61
Configuring Actions....62
Animation....63
JavaFX Properties....65
Property Listeners....66
Invalidation Listeners....66
Change Listeners....68
Subscription-Based Listeners....69
Binding....70
Unidirectional Binding....70
Bidirectional Binding....71
Fluent API and Bindings API....71
Using FXML....72
Controller Class....76
JavaFX Application Class....77
Adding CSS....78
Using Scene Builder....80
Putting It All Together....81
Master-Detail UI....81
The Model....84
Observable Lists....86
Implementing ListView Selection....86
Using Multiple Selection....87
ListView and Sort....88
Person UI Application Actions....89
Delete a Person....89
Add a Person....90
Update a Person....91
Person UI with Records....94
Person Record....95
Key Point Summary....96
Chapter 3: Properties and Bindings....99
Key Concepts....100
Observable and InvalidationListener....101
ObservableValue and ChangeListener....101
Subscription....102
WritableValue and ReadOnlyProperty....102
JavaFX Properties....102
Creating Bindings....109
JavaFX Bindings....109
Create Bindings by Direct Extension....110
Type-Specific Specializations....112
Factory Methods in Bindings....115
Create Bindings with the Fluent API....118
Observable Collections....123
Factory and Utility Methods in FXCollections....123
Change Listeners for Observable Collections....128
Change Events in ListChangeListener....130
Change Events in MapChangeListener....135
Change Events in SetChangeListener....138
Change Events in ArrayChangeListener....140
Create Bindings for Observable Collections....143
JavaFX Beans....143
Eagerly Instantiated Property....144
Half-Lazily Instantiated Property....146
Fully Lazily Instantiated Property....147
Selection Bindings....148
Adapting Java Beans....151
Summary....157
Resources....158
Chapter 4: JavaFX Controls Deep Dive....160
The UI Controls Module....160
What Is a UI Control?....161
JavaFX Basic Controls....162
Labeled Controls....162
Label....163
Button....164
CheckBox....165
Note: in this snippet and in snippets below the log() method is used as a short for System.out.println().....166
Hyperlink....166
ToggleButton....166
RadioButton....168
Text Input Controls....168
TextFormatter....169
TextField, PasswordField, and TextArea....170
Other Simple Controls....171
ProgressBar and ProgressIndicator....171
Slider....172
Container Controls....173
Accordion and TitledPane....173
ButtonBar....174
ScrollPane....175
SplitPane....177
TabPane....178
ToolBar....180
Other Controls....181
HTMLEditor....181
Pagination....181
ScrollBar....183
Separator....183
Spinner....184
Tooltip....185
Popup Controls....186
Menu-Based Controls....186
Menu and MenuItem....186
MenuBar....188
MenuButton and SplitMenuButton....189
ContextMenu....191
ChoiceBox....192
ComboBox-Based Controls....194
ComboBox....195
ColorPicker....196
DatePicker....197
JavaFX Dialogs....198
Alert....199
ChoiceDialog....200
TextInputDialog....200
Dialog and DialogPane....201
Advanced Controls....202
ListView....203
Cells and Cell Factories....204
Cell Editing....206
Pre-built Cell Factories....208
TreeView....208
TableView....210
TableColumn and TreeTableColumn....212
Nested Columns....216
Cell Factories in TableView....216
TreeTableView....217
Selection and Focus Models....220
SelectionModel....220
FocusModel....221
Summary....222
Acknowledgments....222
Chapter 5: Mastering Visual and CSS Design....223
Introduction to Cascading Style Sheets....223
Selectors Based on Class Name....226
Selectors Based on Custom Style Classes....227
Selectors Based on Object ID....227
Applying CSS Styles....227
Loading CSS Stylesheets....227
Applying CSS Styles to JavaFX Nodes....229
Advanced CSS Techniques....232
Using Descendant Selectors....232
Using Pseudo-classes....232
Using Imports....233
Font Loading in the Stylesheet....233
Reusing Styles....234
Using Advanced Color Definitions....235
Using Linear Gradients....235
Using Radial Gradients....236
Using Image Patterns....236
Using RGB Color Definitions....237
Using HSB Color Definitions....239
Using Color Functions....239
Using Effect Definitions....240
Drop Shadow....240
Inner Shadow....241
Useful Tips and Tricks....242
Study the Modena Stylesheet....242
Define Themes Based on Modena....242
Define Icons Using CSS....243
CSS Reusability by Using Color Constants....243
Using Transparent Colors....244
Advanced CSS API....245
Platform Preferences API....253
CSS in JavaFX Applications: Summary....256
Chapter 6: High-Performance Graphics....257
Using Canvas....258
Giving Life to a Canvas Application....264
Particle Systems....269
Fractals....279
High Performance....292
Conclusion....304
Chapter 7: Bridging Swing and JavaFX....305
Integrating JavaFX into Swing....305
JFXPanel: Swing Component with JavaFX Inside....306
Threading....311
Interaction Between Swing and JavaFX....312
Drag and Drop with JavaFX and Swing....320
JavaFX 3D Integrated in Swing....323
Integrating Swing into JavaFX....325
Migration Strategies....327
Large-Scale Integrations....327
Conclusion....328
Chapter 8: JavaFX 3D....329
Prerequisites....329
Getting Started with Shapes....330
Shape3D....335
Sphere....336
Box....337
Cylinder....337
Creating User-Defined 3D Shapes....338
Camera....351
ParallelCamera....352
PerspectiveCamera....352
Light....356
Understanding the LightBase Class....356
Understanding the AmbientLight Class....357
Understanding the PointLight Class....357
Material....365
Understanding the PhongMaterial Class....366
Adding Texture to 3D Shapes....369
Interacting with JavaFX 3D Scenes....373
Understanding the PickResult Class....374
Third-Party Software: FXyz 3D....379
FXyz 3D Sample....380
Conclusion....382
Chapter 9: JavaFX, the Web, and Cloud Infrastructure....383
Integrating with the Web....385
Displaying a Web Page....385
Adding Navigation and History....387
Showing Loading Progress....389
From Web Sites to APIs....390
Building for the Cloud....390
Architecture of a JavaFX Cloud Application....391
Use Case: Querying OpenWeather....393
Conclusion....410
Chapter 10: Packaging Apps for the Desktop....411
Web vs. Desktop Applications....411
Evolutions in Application Deployment....413
The jpackage Tool....415
What Is jpackage?....415
Using jpackage....417
jpackage Usage....418
jpackage Options....418
Requirements....425
WiX Setup....425
Samples....425
Nonmodular Application: Sample1....426
Instructions for Windows....426
Modifying the Installer....430
macOS....431
Modifying the Installer....433
Linux....434
Modular Application: Sample2....435
Windows....436
macOS....437
Linux....438
Gradle Projects....439
Using GraalVM’s Native Image....441
Platform Requirements....442
Requirements for macOS....443
Requirements for Linux....443
Requirements for Windows....443
The Code....444
Maven Project....445
Gradle Project....447
Build the Project....448
Compile....449
Link....450
Run....451
Conclusion....452
Chapter 11: Native Mobile Apps for iOS and Android....453
Why JavaFX on Mobile....454
Different Approaches for Mobile Apps....455
OS-Specific Native Controls....456
Mobile Websites....456
Device Native Rendering....456
Hello, JavaFX on iOS and Android....458
GluonFX Plugins to Reduce Complexity....458
The Development Flow....459
The Code....461
iOS....466
Requirements....466
Build the Project....466
Compile....467
Link and Package....469
Run....469
Android....471
Requirements....471
Compile....471
Link and Package....472
Run....473
How Does It Work?....474
Using the Plugin Options....475
bundlesList....475
resourcesList....476
reflectionList....476
jniList....477
runAgent Task/Goal....477
Creating Real Mobile-Looking Apps....477
Different Stylesheets....478
Mobile-Specific Controls....482
The Code....483
Build the Project....489
Summary....492
Chapter 12: JavaFX 23 on Raspberry Pi....493
Intro to Raspberry Pi....493
Getting Started with a Raspberry Pi....494
Initial Kit....494
Raspberry Pi....494
Power Adaptor....495
SD Card....495
Monitor....496
Install SD....496
Raspberry Pi Configuration....497
raspi-config....498
Remote Connection via SSH....501
Java 21....502
Testing Java 21....503
Installing JavaFX 23....504
64 Bits....504
Sample1....504
Wayland/X11....506
JavaFX Applications Without Windows Manager....507
Direct Rendering Manager (DRM)....507
Running JavaFX Applications Without Windows Manager....508
Sample2....511
Gradle....511
Maven....512
Running JavaFX Applications Remotely....515
Java Remote Platform....516
Gradle SSH Plugin....520
Creating JavaFX Native Images....523
Working with Dependencies....527
The DIY In-Car Navigation System....527
Bill of Materials....527
Setup for GPIO....528
GPIO Connections....529
Required GPS Software....530
NMEA Readings....532
GPIO, Serial Port, and Java....539
jSerialComm....539
GPS Service....540
The UI....543
Gluon Maps....544
Afterburner....546
Scene Builder....546
The Application Class....556
Deploy and Test....562
Next Challenge....563
Conclusions....564
Chapter 13: Machine Learning and JavaFX....565
What Is Machine Learning....565
Supervised Learning....566
Unsupervised Learning....566
Artificial Neural Networks....566
Convolutional Neural Networks....568
Eclipse DeepLearning4J: Java API for Neural Networks....570
Training Neural Networks from a JavaFX Application....573
Read an Image from JavaFX to a Neural Network....578
Detecting Objects in a Video....583
Chapter 14: Scientific Applications Using JavaFX....592
JavaFX for Space Exploration....592
JavaFX for Quantum Computing....594
Using JShell....597
Using JShell....599
About ND4J....602
Using ND4J in JShell....606
Using JavaFX in JShell....611
Starting Stand-Alone JavaFX Code....612
JavaFX Applications in JShell....614
JavaFX Libraries in JShell....617
Conclusion....622
Index....623
Build enhanced visual experiences and design and deploy modern, easy-to-maintain, client applications across a variety of platforms. This book will show you how these applications can take advantage of the latest user interface components, 3D technology, and cloud services to create immersive visualizations and allow high-value data manipulation.The Definitive Guide to Modern Java Clients with JavaFX is a professional reference for building Java applications for desktop, mobile, and embedded in the Cloud age. It offers end-to-end coverage of the latest features in JavaFX and Java 13. After reading this book, you will be equipped to upgrade legacy client applications, develop cross-platform applications in Java, and build enhanced desktop and mobile native clients.
Professional Java developers who are interested in learning the latest client Java development techniques to fill out their skillset.