public final Optional<R> showAndWait ()

Shows the dialog and waits for the user response (in other words, brings up a blocking dialog, with the returned value the users input).

This method must be called on the JavaFX Application thread. Additionally, it must either be called from an input event handler or from the run method of a Runnable passed to Platform.runLater. It must not be called during animation or layout processing.

Returns:  An Optional that contains the result. Refer to the Dialog class documentation for more detail.

Exceptions:
IllegalStateException    if this method is called on a thread other than the JavaFX Application Thread.
IllegalStateException    if this method is called during animation or layout processing.