buggaby buggaby - 1 year ago 80
Java Question

Can't use TextInputDialog in Eclipse Neon

I'm trying to run a program that uses the JavaFX scene object TextInputDialog. For some reason, it doesn't allow me to import javafx.scene.control.TextInputDialog (says "cannot be resolved").

I'm new to JavaFX, but here is what I tried. I thought it was my Java version, so I updated to the latest (1.8.0_91). I'm using Eclipse Neon 4.6.0. To install JavaFX it used the "install new software" option in the help menu, and put in the link found in step 4 of this: https://www.eclipse.org/efxclipse/install.html. After that, most of the JavaFX functions worked by adding the requisite import command. But this one doesn't.

I also found that some people have included the JavaFX library in the build path. I didn't change anything when I did that (though I'm not sure exactly what that would do since I already installed JavaFX in Eclipse).

Anyway, any suggestions would be very welcome. Thanks!

Answer Source

You need to make sure that eclipse is using the newer JRE for this project. You can do this by going to Project > Properties > Java Build Path and selecting the newer JRE from the list. I believe it needs to be 1.8.0_45 or newer.