Java Reference
In-Depth Information
Ta b l e 5 . 5
javafx.ext.swing to javax.swing class Mapping
javafx.ext.swing class
javax.swing class
SwingButton
javax.swing.JButton
SwingCheckBox
javax.swing.JCheckBox
SwingComboBox
javax.swing.JComboBox
SwingIcon
javax.swing.Icon
SwingLabel
javax.swing.JLabel
SwingList
javax.swing.JList
SwingRadioButton
javax.swing.JRadioButton
SwingScrollPane
javax.swing.JScrollPane
SwingSlider
javax.swing.JSlider
SwingTextField
javax.swing.JTextField
SwingToggleButton
javax.swing.JToggleButton
All the JavaFX Swing classes also extend javafx.scene.Node , so they can be
added to a scene or other node container such as javafx.scene.Group . The
scene graph can freely intermix these nodes with non-Swing nodes.
All the JavaFX Swing classes extend javafx.scene.SwingComponent. This class
has an abstract function, createJComponent(): JComponent , that the subclass
uses to actually instantiate the corresponding Java Swing class. In addition, the
SwingComponent class has a function, getJComponent(): JComponent , that returns
the underlying javax.swing.JComponent object. This object can then be cast to
the specific Java Swing class. For example, when using a SwingTextField
object stored in the variable jtextfield :
var jtextfield = textfield.getJComponent() as JTextField;
Most of the JavaFX Swing classes implement a function that does this conver-
sion. For example, in SwingTextField there is a function, getJTextField():
JTextField , that does this.
If you have a Java class that extends JComponent , you can use that class in JavaFX
by wrapping it via the SwingComponent.wrap() function. For example,
Search WWH ::




Custom Search