< prev index next >
modules/javafx.controls/src/main/java/javafx/scene/control/Dialog.java
Print this page
@@ -99,15 +99,16 @@
* (assuming it has already been set in the {@link DialogPane#getButtonTypes()}
* list. The returned Node is typically of type {@link Button}, but this depends
* on if the {@link DialogPane#createButton(ButtonType)} method has been overridden. A
* typical approach is therefore along the following lines:
*
- * <pre>{@code ButtonType loginButtonType = new ButtonType("Login", ButtonData.OK_DONE);
- * Dialog<String> dialog = new Dialog<>();
- * dialog.getDialogPane().getButtonTypes().add(loginButtonType);
- * boolean disabled = false; // computed based on content of text fields, for example
- * dialog.getDialogPane().lookupButton(loginButtonType).setDisable(disabled);}</pre>
+ * <pre>{@code
+ * ButtonType loginButtonType = new ButtonType("Login", ButtonData.OK_DONE);
+ * Dialog<String> dialog = new Dialog<>();
+ * dialog.getDialogPane().getButtonTypes().add(loginButtonType);
+ * boolean disabled = false; // computed based on content of text fields, for example
+ * dialog.getDialogPane().lookupButton(loginButtonType).setDisable(disabled);}</pre>
*
* <p>Once a Dialog is instantiated and fully configured, the next step is to
* show it. More often than not, dialogs are shown in a modal and blocking
* fashion. 'Modal' means that the dialog prevents user interaction with the
* owning application whilst it is showing, and 'blocking' means that code
@@ -123,24 +124,27 @@
* developers should choose to use {@link #showAndWait()}, given the ease of
* coding in these situations. Shown below is three code snippets, showing three
* equally valid ways of showing a dialog:
*
* <p><strong>Option 1: The 'traditional' approach</strong>
- * <pre>{@code Optional<ButtonType> result = dialog.showAndWait();
+ * <pre>{@code
+ * Optional<ButtonType> result = dialog.showAndWait();
* if (result.isPresent() && result.get() == ButtonType.OK) {
* formatSystem();
* }}</pre>
*
* <p><strong>Option 2: The traditional + Optional approach</strong>
- * <pre>{@code dialog.showAndWait().ifPresent(response -> {
+ * <pre>{@code
+ * dialog.showAndWait().ifPresent(response -> {
* if (response == ButtonType.OK) {
* formatSystem();
* }
* });}</pre>
*
* <p><strong>Option 3: The fully lambda approach</strong>
- * <pre>{@code dialog.showAndWait()
+ * <pre>{@code
+ * dialog.showAndWait()
* .filter(response -> response == ButtonType.OK)
* .ifPresent(response -> formatSystem());}</pre>
*
* <p>There is no better or worse option of the three listed above, so developers
* are encouraged to work to their own style preferences. The purpose of showing
@@ -1006,11 +1010,11 @@
*
**************************************************************************/
// This code is called both in the normal and in the abnormal case (i.e.
// both when a button is clicked and when the user forces a window closed
- // with keyboard OS-specific shortchuts or OS-native titlebar buttons).
+ // with keyboard OS-specific shortcuts or OS-native titlebar buttons).
@SuppressWarnings("unchecked")
void setResultAndClose(ButtonType cmd, boolean close) {
Callback<ButtonType, R> resultConverter = getResultConverter();
R priorResultValue = getResult();
< prev index next >