forked from v98/ClassroomBookingsSystem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConfirmBox.java
48 lines (38 loc) · 1.2 KB
/
ConfirmBox.java
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
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
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 msg){
Stage window2=new Stage();
window2.initModality(Modality.APPLICATION_MODAL);
window2.setTitle(title);
window2.setMinWidth(300);
Label label=new Label(msg);
Button yes=new Button("Yes");
Button no=new Button("No");
yes.setOnAction(e -> {
answer=true;
window2.close();
});
no.setOnAction(e -> {
answer=false;
window2.close();
});
HBox layout =new HBox(20);
layout.setPadding(new Insets(10,10,10,10));
layout.getChildren().addAll(label,yes,no);
layout.setAlignment(Pos.CENTER);
window2.setScene(new Scene(layout));
window2.showAndWait();
return answer;
}
}