Java Reference
In-Depth Information
the following link for the Javadoc: http://docs.oracle.com/javase/8/
javafx/api/javafx/print/package-summary.html .
14-18.
Embedding
Swing
Content
in
JavaFX
Problem
You want to embed some simple Java Swing content into a JavaFX application.
Solution
Create a JavaFX application and embed the Swing content into it using the
SwingNode class. In the following example, a simple JavaFX application is used to
toggle between a Swing-based user entry form and a JavaFX-based form. A JavaFX
button within the application can be used to determine which of the forms should be
displayed when the user clicks it.
First, let's take a look at the code for the Swing form that is embedded into the
JavaFX application. The code resides in a class entitled SwingForm.java .
import java.awt.GridLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class SwingForm extends JPanel {
JLabel formTitle, first, last, buttonLbl;
protected JTextField firstField, lastField;
public SwingForm(){
JPanel innerPanel = new JPanel();
GridLayout gl = new GridLayout(3,2);
innerPanel.setLayout(gl);
first = new JLabel("First Name:");
Search WWH ::




Custom Search