The Definitive Guide to Modern Java Clients with JavaFX, 3rd Edition Cross-Platform Mobile and Cloud Development Updated for… (Stephen Chin, Johan Vos, James Weaver) (Z-Library)

Author: Stephen Chin, Johan Vos, James Weaver

商业

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 JavaFX’s latest user interface components, 3D technology, and cloud services to create immersive visualizations and allow high-value data manipulation. This book 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 21 and 23. This third edition has been updated to include new features introduced in JavaFX 21 and 23, including NEW APIs: Map, FlatMap, and OrElse fluent bindings for ObservableValue, along with the new Subscription API. Additionally, it's updated to account for new bug fixes and overall improvements to existing functionality in Java. 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. What You Will Learn Create modern client applications in Java using the latest JavaFX 21 and 23 Build enterprise clients that will enable integration with existing cloud services Use advanced visualization and 3D features Deploy on desktop, mobile, and embedded devices Who This Book Is For Professional Java developers who are interested in learning the latest client Java development techniques to fill out their skills set

📄 File Format: PDF
💾 File Size: 18.4 MB
7
Views
0
Downloads
0.00
Total Donations

📄 Text Preview (First 20 pages)

ℹ️

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

📄 Page 1
The Definitive Guide to Modern Java Clients with JavaFX Cross-Platform Mobile and Cloud Development Updated for JavaFX 21 and 23 — Third Edition — Stephen Chin Johan Vos James Weaver
📄 Page 2
The Definitive Guide to Modern Java Clients with JavaFX Cross-Platform Mobile and Cloud Development Updated for JavaFX 21 and 23 Third Edition Stephen Chin Johan Vos James Weaver
📄 Page 3
The Definitive Guide to Modern Java Clients with JavaFX: Cross-Platform Mobile and Cloud Development Updated for JavaFX 21 and 23, Third Edition ISBN-13 (pbk): 979-8-8688-0997-2 ISBN-13 (electronic): 979-8-8688-0998-9 https://doi.org/10.1007/979-8-8688-0998-9 Copyright © 2024 by Stephen Chin, Johan Vos and James Weaver This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director, Apress Media LLC: Welmoed Spahr Acquisitions Editor: Melissa Duffy Development Editor: Laura Berendson Coordinating Editor: Gryffin Winkler Cover designed by eStudioCalamar Image by chevanon on Freepik (www.freepik.com) Distributed to the book trade worldwide by Apress Media, LLC, 1 New York Plaza, New York, NY 10004, U.S.A. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www. springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail booktranslations@springernature.com; for reprint, paperback, or audio rights, please e-mail bookpermissions@springernature.com. Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales web page at http://www.apress.com/bulk-sales. Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub (https://github.com/Apress). For more detailed information, please visit https://www. apress.com/gp/services/source-code. If disposing of this product, please recycle the paper Stephen Chin Belmont, CA, USA James Weaver Marion, IN, USA Johan Vos Gluon Leuven, Belgium
📄 Page 4
iii Table of Contents About the Authors �������������������������������������������������������������������������������������������������� xiii About the Technical Reviewer ���������������������������������������������������������������������������������xv Contributors �����������������������������������������������������������������������������������������������������������xvii Chapter 1: Getting Started with Client Java ������������������������������������������������������������� 1 Java Client Technology in Action ��������������������������������������������������������������������������������������������������� 1 Java Clients in Business ���������������������������������������������������������������������������������������������������������� 2 Gaming and 3D������������������������������������������������������������������������������������������������������������������������������ 3 Mobile Conference Apps ��������������������������������������������������������������������������������������������������������������� 5 A Modern Approach to Client Java ������������������������������������������������������������������������������������������������ 7 Target Mobile First ������������������������������������������������������������������������������������������������������������������� 7 Build for the Cloud ������������������������������������������������������������������������������������������������������������������� 9 Package Your Platform ���������������������������������������������������������������������������������������������������������� 11 Setting Up Your Environment ������������������������������������������������������������������������������������������������������ 12 macOS JDK Installation ��������������������������������������������������������������������������������������������������������� 13 Windows JDK Installation ������������������������������������������������������������������������������������������������������ 14 Linux JDK Installation ������������������������������������������������������������������������������������������������������������ 18 JavaFX Installation ���������������������������������������������������������������������������������������������������������������� 18 Your First Modern Java Client ����������������������������������������������������������������������������������������������������� 20 Coding Client Apps with IntelliJ IDEA������������������������������������������������������������������������������������� 20 Rapid Application Development with Scene Builder �������������������������������������������������������������� 25 The Path to Modern Client Development ������������������������������������������������������������������������������������ 32 Chapter 2: JavaFX Fundamentals ��������������������������������������������������������������������������� 33 JavaFX Stage and Scene Graph �������������������������������������������������������������������������������������������������� 33 JavaFX Is Single-Threaded ���������������������������������������������������������������������������������������������������� 34
📄 Page 5
iv Hierarchical Node Structure �������������������������������������������������������������������������������������������������� 34 A Simple Shape Example ������������������������������������������������������������������������������������������������������������ 36 Color �������������������������������������������������������������������������������������������������������������������������������������������� 38 Text Is a Shape ���������������������������������������������������������������������������������������������������������������������������� 39 The JavaFX Coordinate System��������������������������������������������������������������������������������������������������� 39 Layout Controls ��������������������������������������������������������������������������������������������������������������������������� 40 StackPane ����������������������������������������������������������������������������������������������������������������������������� 40 AnchorPane ��������������������������������������������������������������������������������������������������������������������������� 41 GridPane �������������������������������������������������������������������������������������������������������������������������������� 41 FlowPane and TilePane���������������������������������������������������������������������������������������������������������� 42 BorderPane ���������������������������������������������������������������������������������������������������������������������������� 42 SplitPane ������������������������������������������������������������������������������������������������������������������������������� 43 HBox, VBox, and ButtonBar ���������������������������������������������������������������������������������������������������� 43 Make a Scene ����������������������������������������������������������������������������������������������������������������������������� 43 Enhancing the MyShapes Application ����������������������������������������������������������������������������������������� 44 Linear Gradient ���������������������������������������������������������������������������������������������������������������������� 44 DropShadow �������������������������������������������������������������������������������������������������������������������������� 45 Reflection ������������������������������������������������������������������������������������������������������������������������������ 46 Configuring Actions ��������������������������������������������������������������������������������������������������������������������� 47 Animation ������������������������������������������������������������������������������������������������������������������������������������ 48 JavaFX Properties ����������������������������������������������������������������������������������������������������������������������� 50 Property Listeners ����������������������������������������������������������������������������������������������������������������� 51 Subscription-Based Listeners ����������������������������������������������������������������������������������������������� 54 Binding ���������������������������������������������������������������������������������������������������������������������������������� 55 Using FXML ��������������������������������������������������������������������������������������������������������������������������������� 57 Controller Class ��������������������������������������������������������������������������������������������������������������������� 61 Putting It All Together ������������������������������������������������������������������������������������������������������������������ 66 Master-Detail UI ��������������������������������������������������������������������������������������������������������������������� 66 Observable Lists �������������������������������������������������������������������������������������������������������������������� 71 Person UI Application Actions ������������������������������������������������������������������������������������������������ 74 Table of ConTenTs
📄 Page 6
v Person UI with Records ��������������������������������������������������������������������������������������������������������� 79 Key Point Summary ��������������������������������������������������������������������������������������������������������������������� 81 Chapter 3: Properties and Bindings ������������������������������������������������������������������������ 85 Key Concepts ������������������������������������������������������������������������������������������������������������������������������ 86 Observable and InvalidationListener ������������������������������������������������������������������������������������� 87 ObservableValue and ChangeListener ����������������������������������������������������������������������������������� 87 Subscription �������������������������������������������������������������������������������������������������������������������������� 88 WritableValue and ReadOnlyProperty ������������������������������������������������������������������������������������ 88 JavaFX Properties ������������������������������������������������������������������������������������������������������������������ 88 Creating Bindings ������������������������������������������������������������������������������������������������������������������������ 95 JavaFX Bindings �������������������������������������������������������������������������������������������������������������������� 95 Create Bindings by Direct Extension ������������������������������������������������������������������������������������� 96 Type-Specific Specializations ����������������������������������������������������������������������������������������������������� 98 Factory Methods in Bindings ���������������������������������������������������������������������������������������������������� 101 Create Bindings with the Fluent API ������������������������������������������������������������������������������������������ 104 Observable Collections�������������������������������������������������������������������������������������������������������������� 109 Factory and Utility Methods in FXCollections ���������������������������������������������������������������������� 109 Change Listeners for Observable Collections ���������������������������������������������������������������������� 114 Create Bindings for Observable Collections ������������������������������������������������������������������������ 129 JavaFX Beans ���������������������������������������������������������������������������������������������������������������������������� 129 Eagerly Instantiated Property ���������������������������������������������������������������������������������������������� 130 Half-Lazily Instantiated Property ����������������������������������������������������������������������������������������� 132 Fully Lazily Instantiated Property ���������������������������������������������������������������������������������������� 133 Selection Bindings ��������������������������������������������������������������������������������������������������������������� 134 Adapting Java Beans ����������������������������������������������������������������������������������������������������������� 137 Summary����������������������������������������������������������������������������������������������������������������������������������� 143 Resources ��������������������������������������������������������������������������������������������������������������������������������� 144 Chapter 4: JavaFX Controls Deep Dive������������������������������������������������������������������ 147 The UI Controls Module ������������������������������������������������������������������������������������������������������������� 147 What Is a UI Control? ����������������������������������������������������������������������������������������������������������������� 148 Table of ConTenTs
📄 Page 7
vi JavaFX Basic Controls ��������������������������������������������������������������������������������������������������������������� 149 Labeled Controls ������������������������������������������������������������������������������������������������������������������ 149 Text Input Controls ��������������������������������������������������������������������������������������������������������������� 155 Other Simple Controls���������������������������������������������������������������������������������������������������������� 158 Container Controls �������������������������������������������������������������������������������������������������������������������� 160 Accordion and TitledPane ���������������������������������������������������������������������������������������������������� 160 ButtonBar ���������������������������������������������������������������������������������������������������������������������������� 161 ScrollPane ��������������������������������������������������������������������������������������������������������������������������� 162 SplitPane ����������������������������������������������������������������������������������������������������������������������������� 164 TabPane ������������������������������������������������������������������������������������������������������������������������������� 165 ToolBar ��������������������������������������������������������������������������������������������������������������������������������� 167 Other Controls ��������������������������������������������������������������������������������������������������������������������������� 168 HTMLEditor �������������������������������������������������������������������������������������������������������������������������� 168 Pagination ���������������������������������������������������������������������������������������������������������������������������� 168 ScrollBar ������������������������������������������������������������������������������������������������������������������������������ 170 Separator ����������������������������������������������������������������������������������������������������������������������������� 170 Spinner �������������������������������������������������������������������������������������������������������������������������������� 171 Tooltip ���������������������������������������������������������������������������������������������������������������������������������� 172 Popup Controls �������������������������������������������������������������������������������������������������������������������������� 173 Menu-Based Controls ���������������������������������������������������������������������������������������������������������� 173 ComboBox-Based Controls �������������������������������������������������������������������������������������������������� 181 JavaFX Dialogs �������������������������������������������������������������������������������������������������������������������������� 185 Alert ������������������������������������������������������������������������������������������������������������������������������������� 186 ChoiceDialog ������������������������������������������������������������������������������������������������������������������������ 187 TextInputDialog �������������������������������������������������������������������������������������������������������������������� 187 Dialog and DialogPane��������������������������������������������������������������������������������������������������������� 188 Advanced Controls �������������������������������������������������������������������������������������������������������������������� 189 ListView ������������������������������������������������������������������������������������������������������������������������������� 190 TreeView ������������������������������������������������������������������������������������������������������������������������������ 195 TableView ���������������������������������������������������������������������������������������������������������������������������� 197 TreeTableView ���������������������������������������������������������������������������������������������������������������������� 204 Table of ConTenTs
📄 Page 8
vii Selection and Focus Models ����������������������������������������������������������������������������������������������������� 207 SelectionModel �������������������������������������������������������������������������������������������������������������������� 207 FocusModel ������������������������������������������������������������������������������������������������������������������������� 208 Summary����������������������������������������������������������������������������������������������������������������������������������� 209 Acknowledgments ��������������������������������������������������������������������������������������������������������������� 209 Chapter 5: Mastering Visual and CSS Design ������������������������������������������������������� 211 Introduction to Cascading Style Sheets ������������������������������������������������������������������������������������ 211 Selectors Based on Class Name ������������������������������������������������������������������������������������������ 214 Selectors Based on Custom Style Classes �������������������������������������������������������������������������� 215 Selectors Based on Object ID ���������������������������������������������������������������������������������������������� 215 Applying CSS Styles ������������������������������������������������������������������������������������������������������������������ 215 Loading CSS Stylesheets ����������������������������������������������������������������������������������������������������� 215 Applying CSS Styles to JavaFX Nodes ��������������������������������������������������������������������������������� 217 Advanced CSS Techniques �������������������������������������������������������������������������������������������������������� 220 Using Descendant Selectors ������������������������������������������������������������������������������������������������ 220 Using Pseudo-classes ��������������������������������������������������������������������������������������������������������� 220 Using Imports ���������������������������������������������������������������������������������������������������������������������� 221 Font Loading in the Stylesheet �������������������������������������������������������������������������������������������� 221 Reusing Styles ��������������������������������������������������������������������������������������������������������������������� 222 Using Advanced Color Definitions ���������������������������������������������������������������������������������������� 223 Using Linear Gradients �������������������������������������������������������������������������������������������������������� 223 Using Radial Gradients �������������������������������������������������������������������������������������������������������� 224 Using Image Patterns ���������������������������������������������������������������������������������������������������������� 224 Using RGB Color Definitions ������������������������������������������������������������������������������������������������ 225 Using HSB Color Definitions ������������������������������������������������������������������������������������������������ 227 Using Color Functions ���������������������������������������������������������������������������������������������������������� 227 Using Effect Definitions ������������������������������������������������������������������������������������������������������� 228 Useful Tips and Tricks ���������������������������������������������������������������������������������������������������������� 230 Advanced CSS API ��������������������������������������������������������������������������������������������������������������������� 233 Platform Preferences API ���������������������������������������������������������������������������������������������������������� 241 CSS in JavaFX Applications: Summary ������������������������������������������������������������������������������������� 244 Table of ConTenTs
📄 Page 9
viii Chapter 6: High-Performance Graphics ���������������������������������������������������������������� 245 Using Canvas ���������������������������������������������������������������������������������������������������������������������������� 246 Giving Life to a Canvas Application ������������������������������������������������������������������������������������������� 252 Particle Systems ����������������������������������������������������������������������������������������������������������������������� 257 Fractals ������������������������������������������������������������������������������������������������������������������������������������� 267 High Performance ��������������������������������������������������������������������������������������������������������������������� 280 Conclusion �������������������������������������������������������������������������������������������������������������������������������� 292 Chapter 7: Bridging Swing and JavaFX ���������������������������������������������������������������� 293 Integrating JavaFX into Swing �������������������������������������������������������������������������������������������������� 293 JFXPanel: Swing Component with JavaFX Inside ���������������������������������������������������������������� 294 Threading ���������������������������������������������������������������������������������������������������������������������������� 299 Interaction Between Swing and JavaFX ������������������������������������������������������������������������������ 300 Drag and Drop with JavaFX and Swing ������������������������������������������������������������������������������������� 308 JavaFX 3D Integrated in Swing ������������������������������������������������������������������������������������������������� 311 Integrating Swing into JavaFX �������������������������������������������������������������������������������������������������� 313 Migration Strategies ����������������������������������������������������������������������������������������������������������������� 315 Large-Scale Integrations ����������������������������������������������������������������������������������������������������������� 315 Conclusion �������������������������������������������������������������������������������������������������������������������������������� 316 Chapter 8: JavaFX 3D ������������������������������������������������������������������������������������������� 317 Prerequisites ����������������������������������������������������������������������������������������������������������������������������� 317 Getting Started with Shapes ����������������������������������������������������������������������������������������������������� 318 Shape3D ������������������������������������������������������������������������������������������������������������������������������ 323 Sphere ��������������������������������������������������������������������������������������������������������������������������������� 324 Box��������������������������������������������������������������������������������������������������������������������������������������� 325 Cylinder ������������������������������������������������������������������������������������������������������������������������������� 325 Creating User-Defined 3D Shapes ��������������������������������������������������������������������������������������� 326 Camera �������������������������������������������������������������������������������������������������������������������������������������� 339 ParallelCamera �������������������������������������������������������������������������������������������������������������������� 340 PerspectiveCamera ������������������������������������������������������������������������������������������������������������� 340 Table of ConTenTs
📄 Page 10
ix Light ������������������������������������������������������������������������������������������������������������������������������������������ 344 Understanding the LightBase Class ������������������������������������������������������������������������������������� 344 Understanding the AmbientLight Class ������������������������������������������������������������������������������� 345 Understanding the PointLight Class ������������������������������������������������������������������������������������ 345 Material ������������������������������������������������������������������������������������������������������������������������������������� 353 Understanding the PhongMaterial Class ����������������������������������������������������������������������������� 354 Adding Texture to 3D Shapes ����������������������������������������������������������������������������������������������� 357 Interacting with JavaFX 3D Scenes ������������������������������������������������������������������������������������������ 361 Understanding the PickResult Class ������������������������������������������������������������������������������������ 362 Third-Party Software: FXyz 3D �������������������������������������������������������������������������������������������������� 367 FXyz 3D Sample ������������������������������������������������������������������������������������������������������������������� 368 Conclusion �������������������������������������������������������������������������������������������������������������������������������� 370 Chapter 9: JavaFX, the Web, and Cloud Infrastructure ����������������������������������������� 371 Integrating with the Web ����������������������������������������������������������������������������������������������������������� 373 Displaying a Web Page �������������������������������������������������������������������������������������������������������� 373 Adding Navigation and History �������������������������������������������������������������������������������������������� 375 Showing Loading Progress �������������������������������������������������������������������������������������������������� 377 From Web Sites to APIs �������������������������������������������������������������������������������������������������������� 378 Building for the Cloud ��������������������������������������������������������������������������������������������������������������� 378 Architecture of a JavaFX Cloud Application ������������������������������������������������������������������������� 379 Use Case: Querying OpenWeather ��������������������������������������������������������������������������������������� 381 Conclusion �������������������������������������������������������������������������������������������������������������������������������� 398 Chapter 10: Packaging Apps for the Desktop ������������������������������������������������������� 399 Web vs� Desktop Applications ��������������������������������������������������������������������������������������������������� 399 Evolutions in Application Deployment ��������������������������������������������������������������������������������������� 401 The jpackage Tool ��������������������������������������������������������������������������������������������������������������������� 403 What Is jpackage? ��������������������������������������������������������������������������������������������������������������� 403 Using jpackage �������������������������������������������������������������������������������������������������������������������� 405 Using GraalVM’s Native Image �������������������������������������������������������������������������������������������������� 429 Platform Requirements �������������������������������������������������������������������������������������������������������� 430 The Code ������������������������������������������������������������������������������������������������������������������������������ 432 Table of ConTenTs
📄 Page 11
x Maven Project ���������������������������������������������������������������������������������������������������������������������� 433 Gradle Project ���������������������������������������������������������������������������������������������������������������������� 435 Build the Project ������������������������������������������������������������������������������������������������������������������ 436 Compile ������������������������������������������������������������������������������������������������������������������������������� 437 Conclusion �������������������������������������������������������������������������������������������������������������������������������� 440 Chapter 11: Native Mobile Apps for iOS and Android ������������������������������������������� 441 Why JavaFX on Mobile �������������������������������������������������������������������������������������������������������������� 442 Different Approaches for Mobile Apps ��������������������������������������������������������������������������������� 443 OS-Specific Native Controls ������������������������������������������������������������������������������������������������������ 444 Mobile Websites ������������������������������������������������������������������������������������������������������������������������ 444 Device Native Rendering ����������������������������������������������������������������������������������������������������������� 444 Hello, JavaFX on iOS and Android ��������������������������������������������������������������������������������������������� 446 GluonFX Plugins to Reduce Complexity ������������������������������������������������������������������������������� 446 The Development Flow �������������������������������������������������������������������������������������������������������� 447 The Code ������������������������������������������������������������������������������������������������������������������������������ 449 How Does It Work? �������������������������������������������������������������������������������������������������������������������� 462 Using the Plugin Options ����������������������������������������������������������������������������������������������������������� 463 bundlesList �������������������������������������������������������������������������������������������������������������������������� 463 resourcesList ����������������������������������������������������������������������������������������������������������������������� 464 reflectionList ������������������������������������������������������������������������������������������������������������������������ 464 jniList ����������������������������������������������������������������������������������������������������������������������������������� 465 runAgent Task/Goal�������������������������������������������������������������������������������������������������������������� 465 Creating Real Mobile-Looking Apps ������������������������������������������������������������������������������������������ 465 Different Stylesheets ����������������������������������������������������������������������������������������������������������� 466 Mobile-Specific Controls ����������������������������������������������������������������������������������������������������� 470 Summary����������������������������������������������������������������������������������������������������������������������������������� 480 Chapter 12: JavaFX 23 on Raspberry Pi ��������������������������������������������������������������� 481 Intro to Raspberry Pi ����������������������������������������������������������������������������������������������������������������� 481 Getting Started with a Raspberry Pi ������������������������������������������������������������������������������������������ 482 Initial Kit ������������������������������������������������������������������������������������������������������������������������������ 482 Table of ConTenTs
📄 Page 12
xi Java 21 �������������������������������������������������������������������������������������������������������������������������������� 490 Installing JavaFX 23 ������������������������������������������������������������������������������������������������������������ 492 Running JavaFX Applications Remotely ������������������������������������������������������������������������������ 503 Creating JavaFX Native Images ������������������������������������������������������������������������������������������� 511 Working with Dependencies ������������������������������������������������������������������������������������������������ 515 Deploy and Test ������������������������������������������������������������������������������������������������������������������� 550 Conclusions ������������������������������������������������������������������������������������������������������������������������������� 552 Chapter 13: Machine Learning and JavaFX ���������������������������������������������������������� 553 What Is Machine Learning �������������������������������������������������������������������������������������������������������� 553 Supervised Learning ����������������������������������������������������������������������������������������������������������������� 554 Unsupervised Learning ������������������������������������������������������������������������������������������������������������� 554 Artificial Neural Networks ��������������������������������������������������������������������������������������������������������� 554 Convolutional Neural Networks ������������������������������������������������������������������������������������������������� 556 Eclipse DeepLearning4J: Java API for Neural Networks ����������������������������������������������������������� 558 Training Neural Networks from a JavaFX Application ��������������������������������������������������������������� 561 Read an Image from JavaFX to a Neural Network �������������������������������������������������������������������� 566 Detecting Objects in a Video ����������������������������������������������������������������������������������������������������� 571 Chapter 14: Scientific Applications Using JavaFX ������������������������������������������������ 581 JavaFX for Space Exploration ��������������������������������������������������������������������������������������������������� 581 JavaFX for Quantum Computing ����������������������������������������������������������������������������������������������� 583 Using JShell ������������������������������������������������������������������������������������������������������������������������������ 586 Using JShell ������������������������������������������������������������������������������������������������������������������������� 588 About ND4J �������������������������������������������������������������������������������������������������������������������������� 591 Using ND4J in JShell ����������������������������������������������������������������������������������������������������������� 595 Using JavaFX in JShell �������������������������������������������������������������������������������������������������������� 600 Conclusion �������������������������������������������������������������������������������������������������������������������������������� 611 Index ��������������������������������������������������������������������������������������������������������������������� 613 Table of ConTenTs
📄 Page 13
xiii About the Authors Stephen Chin is VP of Developer Relations at Neo4j and author of additional titles including Raspberry Pi with Java, Pro JavaFX Platform, and DevOps Tools for Java Developers. He has keynoted numerous conferences around the world, including AI DevSummit, Devoxx, DevNexus, JNation, JavaOne, Joker, swampUP, and Open Source India. Stephen is an avid motorcyclist who has done evangelism tours in Europe, Japan, and Brazil, interviewing hackers in their natural habitat. When he is not traveling, he enjoys teaching kids how to do AI, embedded, and robot programming together with his daughters. Johan Vos started to work with Java in 1995. He was part of the Blackdown team, porting Java to Linux. His main focus is on end-to-end Java, combining back-end systems and mobile/embedded devices. He received a Duke Choice award in 2014 for his work on JavaFX on mobile. In 2015, he co-founded Gluon, which allows enterprises to create (mobile) Java Client applications leveraging their existing backend infrastructure. Gluon received a Duke Choice award in 2015. Johan is a Java Champion and an Oracle Developer Champion and a member of the BeJUG steering group, the Devoxx steering group, and a JCP member. He has been a speaker at numerous conferences on Java. James Weaver is a Java developer, author, and speaker with a passion for cloud-native applications, machine learning, and quantum computing. He is a Java Champion and a JavaOne Rockstar. James has written books including Inside Java, Beginning J2EE, the Pro JavaFX series, and Java with Raspberry Pi. As a Pivotal Developer Advocate, James speaks internationally at software technology conferences. He tweets at @JavaFXpert.
📄 Page 14
xv About the Technical Reviewer José Pereda, PhD, who specializes in structural engineering, works as a software engineer at Gluon Software. He is a Java Champion and JavaOne Rockstar. Having worked with Java since 1999, he is a JavaFX advocate, developing Java applications for mobile and embedded platforms connected to the cloud and enterprise systems, while he is an active member of OpenJFX (with reviewer role, https://openjdk.org/ census#jpereda) and other open source projects like FXyz 3D (https://github. com/jperedadnr), co-authors JavaFX-related books (such as JavaFX 8: Introduction by Example, JavaFX 9 by Example, and The Definitive Guide to Modern Java Clients with JavaFX, all published by Apress), blogs (http://jperedadnr.blogspot.com. es/), tweets (@JPeredaDnr), and speaks at JUGs and conferences (JavaOne, Devoxx, JAX, Jfokus, JavaLand, JCrete, JBCNConf, to name a few). José lives with his family in Valladolid, Spain.
📄 Page 15
xvii Contributors We would like to express our gratitude to the contributors who helped lay the foundation for this book with their insights and expertise in past editions. In particular, we extend our thanks to: Gail C. Anderson Paul L. Anderson Bruno Borges Anton Epple Weiqi Gao Jonathan Giles José Pereda Sven Reimers Eugene Ryzhikov William Antônio Siqueira
📄 Page 16
1 © Stephen Chin, Johan Vos and James Weaver 2024 S. Chin et al., The Definitive Guide to Modern Java Clients with JavaFX, https://doi.org/10.1007/979-8-8688-0998-9_1 CHAPTER 1 Getting Started with Client Java Written by Stephen Chin Client technologies are the basis for building any interface that users interact with. Because they are the first part of an application that a user sees, they also leave the greatest impact on your audience. Therefore, it is important that user interfaces look good and also are easy to use and intuitive. Whether it be desktop, mobile, tablet, or embedded devices, Java client technologies provide a simple and elegant solution to building modern user experiences. Because the Java language is cross-platform, this reduces the effort to build and maintain your application for multiple screens and form factors. Also, as one of the most widely used programming languages, anyone can help maintain your code, making it a solid foundation for the future. In this chapter, we will show some examples of Java client technology in action and guide you through building your own cross-platform client to demonstrate how easy it is to accomplish this. Java Client Technology in Action Java client technology has been used for decades for all sorts of applications from business applications to development tools and even games. Also, now that Java runs on mobile and embedded platforms, you also find Java applications on your phone, tablet, and Raspberry Pi devices. It is often hard to tell if you are using a Java application because it is packaged together with the required Java libraries, so it appears just like any other native application. We will explore several different Java client applications that you may or may not have used to give you an idea of the potential of this technology.
📄 Page 17
2 Java Clients in Business Java client technology is a staple in enterprise companies for internal applications. This is because it is great at building highly customized applications with complex controls like graphs, trees, tables, and Gantt charts. By building applications once and taking advantage of Java’s cross-platform capabilities, enterprises save on initial implementation cost as well as maintenance. Common use cases for Java client technology in the industry are high-speed trading, train monitoring and scheduling, supply chain management, medical imaging, and inventory management. MINT systems make a training and resource management system (TRMS) that has been adopted by numerous commercial airlines such as Emirates Airlines, JetBlue Airways, Azul Linhas Aéreas Brasileiras, FedEx Express, Lufthansa Group, and the Avianca-Taca Group.1 Figure 1-1. MINT software system for airline training and resource management2 1 MINT Software Systems – European Airline Training Symposium (EATS). Retrieved from www.eats-event.com/mint/. July 19, 2019. 2 Casall, Alexander. 20 JavaFX real-world applications. Retrieved from https://jaxenter. com/20-javafx-real-world-applications-123653.html. February 11, 2016. See also https://www.jfx-central.com/real_world/mint Chapter 1 GettinG Started with Client Java
📄 Page 18
3 Figure 1-1 shows one of the more complex user interface screens from MINT TRMS. It makes use of trees, tables, ribbons, and Gantt charts implemented using the latest Java client technology, JavaFX. JavaFX is a user interface toolkit that provides all of the layouts, controls, and charts that you need to build modern applications. This demonstrates a very complex view that would be challenging to implement in any other cross-platform technology. To find out more about how you can easily build complex applications using pre- built JavaFX controls, check out Chapter 4, “JavaFX Controls Deep Dive.” Gaming and 3D Java client technology is also great for building games. One of the most popular games of all time was built by a single person using Java technology. Markus Persson (aka Notch) released a development version of Minecraft in 2009.3 All the initial development was done in his spare time until the alpha release made enough money so he could start his own company, Mojang, and focus on the game full time. It is now the world’s second highest-grossing video game with 91 million monthly users.4 3 Wikipedia. Minecraft. Retrieved from https://en.wikipedia.org/wiki/Minecraft. August 2019. 4 Gilbert, Ben. “Minecraft” is still one of the biggest games in the world, with over 91 million people playing monthly. Retrieved from www.businessinsider.com/minecraft-has-74- million-monthly-players-2018-1. October 2018. Chapter 1 GettinG Started with Client Java
📄 Page 19
4 Figure 1-2. Minecraft server example from Tingsterland created by @tingsterchin5 Much of the success of Minecraft is through the large modding community who builds plugins that change the behavior of and enhance the game, taking it far beyond the original gameplay limitations. An example of a customer Minecraft server created by a young developer is shown in Figure 1-2. Java offers a great platform for building extensible applications through dynamic class loading and a secure sandbox model. Also with 12 million Java developers worldwide,6 there is no shortage of development expertise and talent. The Minecraft Java Edition is built entirely in Java using client technologies such as Swing and Java 2D and a Java gaming library called LWJGL. The high level of abstraction offered by Java and these libraries made it possible for Notch to develop Minecraft in a short period of time and support a variety of platforms without a large team of developers. 5 Screenshot from a Minecraft server running at https://tingsterland.com/ 6 Oracle Makes Developers More Productive with Latest Java Release. Retrieved from www. prnewswire.com/news-releases/oracle-makes-developers-more-productive-with-latest- java- release-300814269.html. March 2019. Chapter 1 GettinG Started with Client Java
📄 Page 20
5 An even easier 3D library to get started with is the built-in 3D support in JavaFX. You can find out more about 3D graphics in Chapter 8, “JavaFX 3D.” Mobile Conference Apps Java client technology is not just for the desktop. Using mobile JavaFX technology developed by Gluon,7 you can run your Java client on phones, tablets, and embedded devices like Raspberry Pi. Existing JavaFX applications can be ported directly to mobile devices with small changes in styling of controls to make them work on different screen sizes. For handling mobile-specific APIs, Gluon offers Gluon Attach, which provides cross-platform integration with hardware features. A great example of JavaFX mobile in action was the Devoxx conference application. This was originally built for the JavaOne conference in San Francisco and contributed to the open source community. The Devoxx conference picked it up and has done a great job extending it to be a general-purpose conference application that serves dozens of Devoxx and Voxxed conferences taking place around the world each year. 7 Official website for Gluon: https://gluonhq.com/ Chapter 1 GettinG Started with Client Java
The above is a preview of the first 20 pages. Register to read the complete e-book.

💝 Support Author

0.00
Total Amount (¥)
0
Donation Count

Login to support the author

Login Now
Back to List