1 package fi.jyu.mit.fxgui;
3 import java.util.Optional;
5 import javafx.scene.control.Alert;
6 import javafx.scene.control.Alert.AlertType;
7 import javafx.scene.control.ButtonBar.ButtonData;
8 import javafx.scene.control.ButtonType;
9 import javafx.scene.control.Control;
10 import javafx.scene.control.TextInputDialog;
11 import javafx.scene.control.Tooltip;
27 public void set(Alert alert);
38 public void set(TextInputDialog dlg);
49 if ( tip == null || tip.isEmpty() ) {
50 node.setTooltip(null);
53 Tooltip tooltip =
new Tooltip();
55 node.setTooltip(tooltip);
66 Alert alert =
new Alert(AlertType.INFORMATION);
67 alert.setTitle(
"Huomautus");
68 alert.setHeaderText(null);
69 alert.setContentText(message);
70 alert.getDialogPane().setPrefSize(200, -1);
71 if ( alertSetter != null ) alertSetter.
set(alert);
93 TextInputDialog dialog =
new TextInputDialog(def);
94 dialog.setHeaderText(null);
95 dialog.setTitle(
"Vastaa");
96 dialog.setContentText(prompt +
":");
97 if ( setter != null ) setter.
set(dialog);
98 Optional<String> answer = dialog.showAndWait();
99 return answer.isPresent() ? answer.get() : null;
125 String buttonYes, String buttonNo,
127 Alert alert =
new Alert(AlertType.CONFIRMATION);
128 alert.setTitle(title);
129 alert.setHeaderText(null);
130 alert.setContentText(question);
132 ButtonType buttonTypeYes =
new ButtonType(buttonYes, ButtonData.OK_DONE);
133 ButtonType buttonTypeCancel =
new ButtonType(buttonNo, ButtonData.CANCEL_CLOSE);
135 alert.getButtonTypes().setAll(buttonTypeYes, buttonTypeCancel);
137 if ( alertSetter != null ) alertSetter.
set(alert);
138 Optional<ButtonType> result = alert.showAndWait();
139 return result.get() == buttonTypeYes;
153 String buttonYes, String buttonNo) {