0

I'm trying to create Dialogs using this code with controls FX:

        // Show the error message.
        Dialogs.create()
            .title("Invalid Fields")
            .masthead("Please correct invalid fields")
            .message(errorMessage)
            .showError();

But not works. Later i read that controls FX not work with Java FX 2.X, so i found javafx.scene.control.Alert so i used this code:

Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("Information Dialog");
alert.setHeaderText("Look, an Information Dialog");
alert.setContentText("I have a great message for you!");

alert.showAndWait();

But still not working. I tried to import manually javafx.scene.control.* and throws the error:

Caused by: java.lang.Error: Unresolved compilation problems: 
    Alert cannot be resolved to a type
    Alert cannot be resolved to a type
    AlertType cannot be resolved to a variable

what im doing wrong? how can i show an dialog/alert message? Regards.

S. Moreno
  • 526
  • 2
  • 7
  • 29
  • Compile the code once and then try to run it. – Harshita Sethi Nov 30 '15 at 12:55
  • `Alert` was added in javaFX 8u40 > javafx 2.X, see [javadoc](https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/Alert.html) – fabian Nov 30 '15 at 12:58
  • My SDK is jfx8_2.1.0.201508240705 so im using java 8u66 but is jfx2.1 (i donwloaded the latest jfx) – S. Moreno Nov 30 '15 at 13:07
  • This may help http://stackoverflow.com/questions/1124788/java-unresolved-compilation-problem – Harshita Sethi Nov 30 '15 at 13:24
  • What platform are you on? On most platforms, a Java 8 JDK will include JavaFX 8 (with the same update version number). – James_D Nov 30 '15 at 13:28
  • Are you using OpenJDK or Oracle's JDK? OpenJDK doesn't bundle JFX in their official release. They call it [OpenJFX](http://openjdk.java.net/projects/openjfx/). – Jonathan Fortin Nov 30 '15 at 14:02
  • I'm using Oracle JDK – S. Moreno Nov 30 '15 at 14:17
  • 1
    Where did you get this jfx8_2.1.0.201508240705 from? JavaFX (8) is bundled with the Java SE 8 (Oracle). There is no need to install/ download a separate package for JavaFX. For Alerts you'll need JavaFX 8u40 or greater. – Puce Nov 30 '15 at 15:04
  • E(fx)clipse http://www.eclipse.org/efxclipse/index.html – S. Moreno Nov 30 '15 at 15:06
  • e(fx)clipse is an eclipse plugin for developing JavaFX applications. As already noted, you don't need to install JavaFX (and I don't actually see anywhere on the e(fx)clipse site where a JavaFX runtime is provided). If you have installed a different version of JavaFX, remove it and just use the one bundled with the JDK. – James_D Nov 30 '15 at 15:23
  • You can donwload a bundle, not only as addon http://efxclipse.bestsolution.at/install.html (im using 64 bits version) – S. Moreno Nov 30 '15 at 15:31
  • It still doesn't say anything about having a copy of the JavaFX SDK in there. go to "Project" -> "Properties" and select the "Libraries" tab. What is listed there? – James_D Nov 30 '15 at 18:39
  • My library in this project: http://imgur.com/MoVvhuh – S. Moreno Dec 01 '15 at 10:12

0 Answers0