-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathConfirmBox.java
More file actions
47 lines (37 loc) · 1.23 KB
/
Copy pathConfirmBox.java
File metadata and controls
47 lines (37 loc) · 1.23 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
package JavaFXDemo;
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.layout.*;
import javafx.scene.control.*;
import javafx.geometry.*;
//Confirm Box allows the Main5 window and ConfirmBox window to interact with each other. It gets input from the user
//and passes it to the main program
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 = new Label();
label.setText(message);
//Create two buttons
Button yesButton = new Button("Yes");
Button noButton = new Button("No");
yesButton.setOnAction(e -> {
answer = true;
window.close();
});
noButton.setOnAction(e -> {
answer = false;
window.close();
});
VBox layout = new VBox(10);
layout.getChildren().addAll(label, yesButton, noButton);
layout.setAlignment(Pos.CENTER);
Scene scene = new Scene(layout);
window.setScene(scene);
window.showAndWait();
return answer;
}
}