-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfirmBox.java
More file actions
48 lines (35 loc) · 1.15 KB
/
ConfirmBox.java
File metadata and controls
48 lines (35 loc) · 1.15 KB
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
46
47
48
package com.company;
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.layout.*;
import javafx.scene.control.*;
import javafx.geometry.*;
public class ConfirmBox {
static boolean answer;
public static boolean display(String title, String message){
Stage window = new Stage();
window.initModality(Modality.APPLICATION_MODAL);
window.setTitle(title);
window.setMinWidth(250);
Label label_message = new Label();
label_message.setText(message);
//Creating two buttons
Button applyButton = new Button("Apply");
Button cancelButton = new Button("Cancel");
applyButton.setOnAction(e -> {
answer = true;
window.close();
});
cancelButton.setOnAction(e -> {
answer = false;
window.close();
});
VBox layout3 = new VBox(30);
layout3.getChildren().addAll(label_message, applyButton, cancelButton);
layout3.setAlignment(Pos.CENTER);
Scene scene_ConBox = new Scene(layout3);
window.setScene(scene_ConBox );
window.showAndWait();
return answer;
}
}