-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfirm.java
More file actions
50 lines (40 loc) · 1.35 KB
/
Confirm.java
File metadata and controls
50 lines (40 loc) · 1.35 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
49
50
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.layout.*;
import javafx.scene.control.*;
import javafx.geometry.*;
public class Confirm
{
static int answer;
public static int show(String message)
{
Stage window = new Stage();
window.initModality(Modality.APPLICATION_MODAL); //Defines a modal window that blocks events from being delivered to any other application window.
window.setTitle("Confirmation");
window.setMinWidth(200);
Button yesB = new Button("Yes");
yesB.setOnAction(e ->
{
answer = 1;
// Platform.exit(); not working
window.close();
});
Button noB = new Button("No");
noB.setOnAction(e ->
{
answer = 0;
// Platform.exit();
window.close();
});
Label label = new Label();
label.setText(message);
VBox layout = new VBox(20);
layout.getChildren().addAll(label, yesB, noB);
layout.setAlignment(Pos.CENTER);
Scene scene = new Scene(layout,1000,1000);
scene.getStylesheets().add(Confirm.class.getResource("stylesheet.css").toExternalForm());
window.setScene(scene);
window.showAndWait();
return answer;
}
}