-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfirmBox.java
More file actions
45 lines (37 loc) · 1017 Bytes
/
ConfirmBox.java
File metadata and controls
45 lines (37 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
public class ConfirmBox
{
static boolean answer;
public static boolean display(String title, String message)
{
Stage stage = new Stage();
stage.initModality(Modality.APPLICATION_MODAL); // block input events with other windows
stage.setTitle(title);
stage.setMinWidth(250);
Label label = new Label();
label.setText(message);
Button yesButton = new Button("Yes");
Button noButton = new Button("No");
yesButton.setOnAction(e -> {
answer = true;
stage.close();
});
noButton.setOnAction(e -> {
answer = false;
stage.close();
});
VBox layout = new VBox(20);
layout.getChildren().addAll(label, yesButton, noButton);
layout.setAlignment(Pos.CENTER);
Scene scene = new Scene(layout);
stage.setScene(scene);
stage.showAndWait();
return answer;
}
}