0

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?

Paul Lammertsma
  • 37,593
  • 16
  • 136
  • 187
user3367768
  • 17
  • 1
  • 6
  • 1
    possible duplicate of [How to create and show common dialog (Error, Warning, Confirmation) in JavaFX 2.0?](http://stackoverflow.com/questions/8309981/how-to-create-and-show-common-dialog-error-warning-confirmation-in-javafx-2) – jewelsea Mar 03 '14 at 11:34

1 Answers1

0

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

user3043627
  • 15
  • 1
  • 6