forked from jarolrod/java-solitaire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExitWindow.java
More file actions
74 lines (54 loc) · 1.54 KB
/
Copy pathExitWindow.java
File metadata and controls
74 lines (54 loc) · 1.54 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package GUI;
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.layout.*;
import javafx.scene.text.Font;
import javafx.scene.control.*;
import com.sun.prism.paint.Color;
import javafx.geometry.*;
public class ExitWindow {
private static boolean _answer;
public static boolean display(String title, String message) {
Stage exit = new Stage();
exit.initModality(Modality.APPLICATION_MODAL);
exit.setTitle(title);
exit.setMinWidth(500);
exit.setMinHeight(300);
Label exitMessage = new Label(message);
exitMessage.setFont(Font.font("Arial", 30));
Button yes = new Button("Yes");
yes.setStyle("-fx-background-color: red;");
yes.setFont(Font.font("Arial", 30));
yes.setPrefSize(120, 50);
Button no = new Button("No");
no.setStyle("-fx-background-color: green;");
no.setFont(Font.font("Arial", 30));
no.setPrefSize(120, 50);
yes.setOnAction(e -> {
_answer = true;
exit.close();
});
yes.setOnMouseEntered(e -> {
yes.setCursor(Cursor.HAND);
});
no.setOnAction(e -> {
_answer = false;
exit.close();
});
no.setOnMouseEntered(e -> {
no.setCursor(Cursor.HAND);
});
VBox layout = new VBox(10);
HBox layout2 = new HBox();
layout.setSpacing(40);
layout2.setSpacing(20);
layout2.getChildren().addAll(yes, no);
layout2.setAlignment(Pos.CENTER);
layout.getChildren().addAll(exitMessage, layout2);
layout.setAlignment(Pos.CENTER);
Scene confirmScene = new Scene(layout);
exit.setScene(confirmScene);
exit.showAndWait();
return _answer;
}
}