Java Reference
In-Depth Information
Figure 14-19 . Using SwingNode to embed a Swing form
How It Works
There are a great number of applications that have been written using the Java Swing
framework. Sometimes it makes sense to make use of those applications from within a
JavaFX application, or embed portions of those Swing applications where it makes
sense. The javafx.embed.swing.SwingNode class makes it possible to embed
a JComponent instance into a JavaFX application with little effort, by passing the
JComponent to the SwingNode setContent() method. The content is re-
painted automatically and all events are forwarded to the JComponent instance
without user intervention.
In the example to this recipe, a simple Java Swing form is embedded by instantiat-
ing a new SwingNode object and passing to it an instance of the class SwingForm .
The Swing content should run on the Event Dispatch Thread (EDT), so any Swing ac-
cess should be made on the EDT. That said, a new thread is created using
 
Search WWH ::




Custom Search