Java Reference
In-Depth Information
How it works...
The form built in this recipe uses the same layout structure as the form found in the recipe
Creating a form with JavaFX controls . The controls are organized in the same manner, using
HBox and VBox layout managers to arrange GUI controls in rows and columns. The difference,
however, is in the controls that are used in the form. Instead of native JavaFX controls, their
Swing counterparts are used.
JavaFX provides a collection of controls that serve as wrappers for standard Swing controls.
The Swing components themselves are encapsulated in instances of javafx.ext.swing.
SwingComponent , which is a Node instance that can be attached to the scene graph.
The code for the recipe uses several of these wrapper classes, including:
F SwingLabel —this class renders the Swing counterpart to the JavaFX Label control.
It wraps and displays the Swing's JLabel control.
F SwingTextField —this wraps the Swing counterpart to JavaFX's TextBox
control. Under the hood, the SwingTextField wrapper class renders the Swing's
JTextField component.
F SwingRadioButton —this class represents Swing's counterpart to the
JavaFX RadioButton control. Internally, the SwingRadioButton renders
the Swing JRadioButton control. To get SwingRadioButton instances
to toggle as a group, you must specify a toggle group through the property
toggleGroup:SwingToggleGroup . In the recipe, we define variable
rdoBtns as the toggle group.
F SwingCheckBox —this class represents Swing's counterpart to the JavaFX control
CheckBox . Under the hood, SwingCheckBox class renders an instance of
Swing's JCheckBox .
F SwingButton —this class represents Swing's counter part to JavaFX Button control.
Under the hood, the SwingButton renders a JButton instance on the screen.
Swing controls wrapped in the SwingComponent classes behave as regular JavaFX nodes
and can be added to the scene graph. To locate an instance of a SwingComponent , we use
the id:String property and function Scene.lookup(id:String) , as is done with native
JavaFX controls.
 
Search WWH ::




Custom Search