JavaFX 2 Dialogs

时间:2021-08-05 19:47:00

http://edu.makery.ch/blog/2012/10/30/javafx-2-dialogs/

————————————————————————————————————————————

When programming a graphical user interface (GUI) there are occasions where you’ll need a simple popup dialog to communicate with the user. In Swing (the predecessor of JavaFX) there is a convenient class called JOptionPane for such dialogs. A similar class doesn’t exist in JavaFX 2.x (yet).

Fortunately, the authors of JavaFX published some user interface controls they are currently working on. Those controls might be added in a future version of JavaFX.

One of those ui controls is a class called Dialogs.java which is exactly what we need.

How To Use the Dialogs

  1. Download the newest javafx-dialogs-x.x.x.jar file from my GitHub Page. I put all necessary classes, css files and images inside this jar.
  2. Add the jar file to your project (usually inside a lib subfolder).
  3. Add the jar file to the project’s classpath: In Eclipse right-click on the jar file | Build Path | Add to Build Path. Now Eclipse knows about the library.
  4. Then add one of the following lines: