The Definitive Guide to Modern Java Clients with JavaFX 17 by Stephen Chin & Johan Vos & James Weaver
Author:Stephen Chin & Johan Vos & James Weaver
Language: eng
Format: epub
ISBN: 9781484272688
Publisher: Apress
JFXPanel: Swing Component with JavaFX Inside
The way to achieve this is to use a special Swing JComponent â the JFXPanel located in the javafx.embed.swing package in the javafx.swing module. It allows you to embed a JavaFX scene graph into a Swing container hierarchy. The interesting method needed from JFXPanel ispublic void setScene(final Scene newScene)
Attaches a Scene object to display in this JFXPanel. This method can be called either on the event dispatch thread or the JavaFX Application Thread.
Swing coding rules require Swing components to always be created and accessed from the Swing event thread. JFXPanel is different in this respect. It can also be managed from the FX Application Thread. This can be helpful in the case of complex scenes, which may demand JavaFX components to be explicitly created on the FX Application Thread.
Besides the threading aspect, which will be discussed in more detail as we progress further through the integration, the first major thing to recognize here is that the JavaFX embedding does not work on a Node or Control level, rather on a full Scene level. So, if there is a need to embed a Node, for example, a Chart, you cannot just add the Chart instance to the Swing component hierarchy. Instead, you have to create a full Scene and add this using JFXPanel as a Swing component wrapper around your Scene.
With this, a full-fledged small example for an integrated JavaFX Scene can be seen in Listing 7-1.
Note
All following examples are reduced as much as possible so that the integration handling becomes obvious, not the architecture in terms of object-oriented or functional programming. Typically, the only thing needed is a main method into which you can copy and paste the example code. If further special code is needed, this is pointed out in the description for the example.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Practical Guide to Azure Cognitive Services by Chris Seferlis & Christopher Nellis & Andy Roberts(6245)
Unity Artificial Intelligence Programming - Fifth Edition by Dr. Davide Aversa(5840)
Serverless ETL and Analytics with AWS Glue by Vishal Pathak Subramanya Vajiraya Noritaka Sekiyama Tomohiro Tanaka Albert Quiroga Ishan Gaur(4854)
Open Source Projects - Beyond Code by John Mertic(3933)
The AI Product Manager's Handbook by Irene Bratsis(3894)
Graph Data Modeling in Python by Gary Hutson and Matt Jackson(3884)
Cloud Auditing Best Practices by Shinesa Cambric & Michael Ratemo(3528)
Aligning Security Operations with the MITRE ATT&CK Framework by Rebecca Blair(3500)
Graph Data Processing with Cypher by Anthapu Ravindranatha;(1694)
Data Literacy in Practice - A complete guide to data literacy and making smarter decisions with data through intelligent actions (2022) by Packt(1674)
Serverless Machine Learning with Amazon Redshift ML: Create, train, and deploy machine learning models using familiar SQL commands by Debu Panda Phil Bates Bhanu Pittampally Sumeet Joshi(1566)
Network Automation with Go by Nicolas Leiva & Michael Kashin(1522)
Unreal Engine 5 Game Development with C++ Scripting by Zhenyu George Li(1325)
Applied Machine Learning and High-Performance Computing on AWS by Mani Khanuja | Farooq Sabir | Shreyas Subramanian | Trenton Potgieter(1314)
Data Literacy in Practice by Angelika Klidas Kevin Hanegan(1311)
Graph Data Processing with Cypher by Ravindranatha Anthapu(1296)
Implementing Multifactor Authentication: Protect your applications from cyberattacks with the help of MFA by Marco Fanti(1184)
Fuzzing Against the Machine: Automate vulnerability research with emulated IoT devices on QEMU by Antonio Nappa Eduardo Blazquez(1168)
The AI Product Manager's Handbook: Develop a product that takes advantage of machine learning to solve AI problems by Irene Bratsis(1024)
