Can we use a JOptionPane
in JavaFX? If yes, then how?
Is there a way that I can popup a message via a dialog box in a JavaFX program as I can do through javax.swing
with JOptionPane.showMessageDialog()
? If not, is there any other alternative?
Can we use a JOptionPane
in JavaFX? If yes, then how?
Is there a way that I can popup a message via a dialog box in a JavaFX program as I can do through javax.swing
with JOptionPane.showMessageDialog()
? If not, is there any other alternative?
From Cay Horstmann's new book Java SE8 for the Really Impatient (Pearson 2014), s. 4.2, he outlines using
Label message = new Label("Cay's message");
as part of his class which extends the Application Class. He describes using a setScene as follows:
stage.setScene(new Scene(message));
The result is a dialog box with the message.
Alternatively, the JavaFX 8 API describes Class SwingNode, which,
is used to embed a Swing content into a JavaFX application