7

I need to create a dialog in JavaFX. I know that I can make the Stage behave like a dialog by modifying modal, owner and resizable properties.

But how do I hide the "minimize" and "maximize" buttons from the Stage window? Typical dialogs only have the "close" button.

ceklock
  • 6,143
  • 10
  • 56
  • 78
  • Maybe this [thread][1] will solve your problem. [1]: http://stackoverflow.com/questions/12912638/how-can-i-remove-only-the-minimise-button-from-stage-components-and-how-can-i – AsirC Jan 05 '13 at 03:10

2 Answers2

23

Under Windows 7, initializing to StageStyle.UTILITY before you show the window will create a window with only a close button and no minimize 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 would like a complete set of basic JavaFX dialogs I would recommend the JavaFX UI sandbox dialogs.

The JavaFX UI Sandbox was not created by me and is not hosted on my site (source is hosted by Oracle). I requested Oracle to document the sandbox dialog API. If you like, you may vote for or comment on the request.

Makery's blog has some minimal 3rd party documentation of the sandbox dialogs, including basic usage examples as well as a backport of the dialog portion to JavaFX 2.2.

Update

The JavaFX UI Sandbox has been superseded by the ControlsFX project.

Update

Java 8u40 will include JavaFX dialogs built into the core platform APIs. You can try an early access release of Java8u40. The relevant class is javafx.scene.control.Dialog and it's related subclasses such as javafx.scene.control.Alert (the Alert class is for showing standard dialogs which are similar to Swing's JOptionPane class - so you don't need to use JOptionPane to get out of the box standard dialog functionality).

Makery wrote a new blog tutorial for dialog functionality provided in Java 8u40.

Related Questions

Community
  • 1
  • 1
jewelsea
  • 150,031
  • 14
  • 366
  • 406
  • @jewelsea, went to your site. Is there a download link for the code just for the popups or jar for the library? I downloaded the entire project which is quite large - just need the dialog stuff. Also examples of how to use your dialogs would help greatly – likejudo Jan 15 '13 at 15:52
  • Updated answer to address your comment Anil. – jewelsea Jan 15 '13 at 23:31
  • I created a backport of JavaFX 8.40 Dialogs to JDK7: https://github.com/BertelSpA/openjfx-dialogs-jdk7 – Paolo Fulgoni Jun 19 '15 at 09:09
  • Thanks for keeping this answer up-to-date. – JRSofty Apr 21 '18 at 18:26
1

You can also try my approach to the custom dialog window for Java FX 8. Both: source code with practical use example, and runnable demo are available in the link below:

https://github.com/bluevoxel/ChooseStage

And that how it's looks like:

enter image description here

bluevoxel
  • 4,978
  • 11
  • 45
  • 63