How to create a JavaFX dialog?

I need to create a dialog in JavaFX. I know that I can make a scene behave like a dialogue, modifying modal, owners and mutable properties.

But how to hide the minimize and maximize buttons from the Scene window? Typical dialogs have only a close button.

+6
java user-interface javafx javafx-2
Jan 05 '13 at 2:50
source share
2 answers

In Windows 7, initializing StageStyle.UTILITY before displaying the window will create a window with a closed button and will not hide or maximize button:

Stage dialog = new Stage(); dialog.initStyle(StageStyle.UTILITY); Scene scene = new Scene(new Group(new Text(25, 25, "Hello World!"))); dialog.setScene(scene); dialog.show(); 

If you need a complete set of basic JavaFX dialogs, I would recommend JavaFX UI sandbox dialogs .

The JavaFX UI Sandbox was not created by me and is not hosted on my site (source hosted by Oracle). I asked Oracle to document the sandbox dialog box . If you want, you can vote or comment on the request.

The Makery Blog contains minimal third-party documentation on sandbox dialogs, including basic usage examples, as well as the back of the dialog part for JavaFX 2.2.

Update

The JavaFX UI sandbox has been replaced by the ControlsFX project .

Update

Java 8u40 will include JavaFX dialogs built into the APIs of the main platform. You can try early access to the Java8u40 release . The corresponding class is javafx.scene.control.Dialog and its associated subclasses, such as javafx.scene.control.Alert (the Alert class is designed to display standard dialogs that are similar to the Swing JOptionPane class, so you don't need to use JOptionPane to exit standard dialog functionality).

Makery has written a new blog tutorial on dialog functionality introduced in Java 8u40 .

Matters Related

  • How to create and show a general dialog (error, warning, confirmation) in JavaFX 2.0?
+20
Jan 05 '13 at 3:19
source share

You can also try my approach to a custom dialog for Java FX 8. Both: source code with a practical use case and an executable demo are available at the link below:

https://github.com/bluevoxel/ChooseStage

And here is what it looks like:

enter image description here

0
Jul 25 '14 at 13:40
source share



All Articles