examples/contacts-example/src/main/java/de/saxsys/mvvmfx/examples/contacts/util/DialogHelper.java
public static void initDialog(BooleanProperty openProperty, final Stage parentStage, Supplier<Parent> rootSupplier) {
		final Stage dialogStage = new Stage(StageStyle.UTILITY);
		dialogStage.initOwner(parentStage);
		dialogStage.initModality(Modality.APPLICATION_MODAL);

		openProperty.addListener((obs, oldValue, newValue) -> {
			if (newValue) {
				// when it is the first time the dialog is made visible (and therefore no scene exists) ...
				if (dialogStage.getScene() == null) {
					// ... we create a new scene and register it in the stage.
					Scene dialogScene = new Scene(rootSupplier.get());
					dialogScene.getStylesheets().add("/contacts.css");
					dialogStage.setScene(dialogScene);
				} else {
					// ... otherwise we simple bring the dialog to front.
					dialogStage.toFront();
				}

				dialogStage.sizeToScene();
				dialogStage.show();
			} else {
				dialogStage.close();
			}
		});

		// when the user clicks on the close button of the dialog window
		// we want to set the property to false
		dialogStage.setOnCloseRequest(event -> openProperty.set(false));
	}
public static void initDialog(BooleanProperty openProperty, final Stage parentStage, Supplier<Parent> rootSupplier) {
		final Stage dialogStage = new Stage(StageStyle.UTILITY);
		dialogStage.initOwner(parentStage);
		dialogStage.initModality(Modality.APPLICATION_MODAL);

		openProperty.addListener((obs, oldValue, newValue) -> {
			if (newValue) {
				// when it is the first time the dialog is made visible (and therefore no scene exists) ...
				if (dialogStage.getScene() == null) {
					// ... we create a new scene and register it in the stage.
					Scene dialogScene = new Scene(rootSupplier.get());
					dialogScene.getStylesheets().add("/contacts.css");
					dialogStage.setScene(dialogScene);
				} else {
					// ... otherwise we simple bring the dialog to front.
					dialogStage.toFront();
				}

				dialogStage.sizeToScene();
				dialogStage.show();
			} else {
				dialogStage.close();
			}
		});

		// when the user clicks on the close button of the dialog window
		// we want to set the property to false
		dialogStage.setOnCloseRequest(event -> openProperty.set(false));
	}
public static void initDialog ( BooleanProperty openProperty , final Stage parentStage , Supplier < Parent > rootSupplier ) { final Stage dialogStage = new Stage ( StageStyle . UTILITY ) ; dialogStage . initOwner ( parentStage ) ; dialogStage . initModality ( Modality . APPLICATION_MODAL ) ; openProperty . addListener ( ( obs , oldValue , newValue ) -> { if ( newValue ) { // when it is the first time the dialog is made visible (and therefore no scene exists) ... if ( dialogStage . getScene ( ) == null ) { // ... we create a new scene and register it in the stage. Scene dialogScene = new Scene ( rootSupplier . get ( ) ) ; dialogScene . getStylesheets ( ) . add ( "/contacts.css" ) ; dialogStage . setScene ( dialogScene ) ; } else { // ... otherwise we simple bring the dialog to front. dialogStage . toFront ( ) ; } dialogStage . sizeToScene ( ) ; dialogStage . show ( ) ; } else { dialogStage . close ( ) ; } } ) ; // when the user clicks on the close button of the dialog window // we want to set the property to false dialogStage . setOnCloseRequest ( event -> openProperty . set ( false ) ) ; }
Use this method to initialize the show/hide listeners for the dialog.

@param openProperty the boolean property that defines whether the dialog
should be shown or hidden. Set this property to <code>true</code> to open
the dialog. Set it to <code>false</code> to close the dialog. When the
dialog is closed by the user by clicking on the close-button of the
window, this property will also be set to <code>false</code> by the
dialog.
@param parentStage the Stage that is used as parent to initialize the
ownership of the dialog. This way modal dialogs can be created.
@param rootSupplier a supplier function that is called when the dialog is
made visible for the first time. This function has to return a
{@link Parent} instance that is used as the root node of the dialog
scene.
Use this method to initialize the show / hide listeners for the dialog .