How to throw out a message in javafx when (let's say) pressing a button?

    2 answers 2

    Starting with Java, the JDK 8u40 dialogs are in the standard library . The simplest example is:

    import javafx.scene.control.Alert; ... Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("Information"); alert.setHeaderText(null); alert.setContentText("Hello World!"); alert.showAndWait(); 

    enter image description here

    Here is a good overview of the available dialogs with examples: JavaFX Dialogs (official)

      You can use ready-made solutions for displaying messages in JavaFX:

      1. JavaFX Dialogs
      2. JFX Message Box (personally used)
      • wildly sorry, but how to "connect" jar-nickname to the project? stupidly throw in the src-folder and use Dialogs.showInformationDialog (...) did not work - nightin_gale
      • You need to add the path to the JAR file in the Class Path. If you use Eclipse, then: the right button on the project -> Build Path -> Add external jars - Rams666
      • Thanks, in Eclipse, I know how .... although I have already figured out how to do it in IDEA - nightin_gale