forked from AlexTheaker04/DCSS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContinueBox.java
More file actions
83 lines (64 loc) · 2.24 KB
/
ContinueBox.java
File metadata and controls
83 lines (64 loc) · 2.24 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
75
76
77
78
79
80
81
82
83
package application;
/*
* Date: 1/11/2021
* Title: ContinueBox
* Author: Catherine Yu, Andrey Zinovyev
* Description: A class that will create a pop up window with a "continue" button
* for the user to click once they have updated the required information
*/
// Imports
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.layout.*;
import javafx.scene.text.TextAlignment;
import javafx.scene.control.*;
import javafx.geometry.*;
public class ContinueBox {
// Static variable.
static boolean answer;
/**
*
* @author Andrey Zinovyev, Catherine Yu
* @param title The title of the window
* @param message A message that appears in the window
* @return Returns 'answer' as true when the continue button is clicked
*/
public static boolean display(String title, String message) {
// Create a new stage.
Stage popWindow = new Stage();
// Setting it up.
popWindow.setTitle(title);
popWindow.setMinWidth(250);
Label label = new Label();
label.setText(message);
// Set the text alignment to center of the label.
label.setTextAlignment(TextAlignment.CENTER);
// Create the continue button
Button continueButton = new Button("Continue.");
// When the "continue" button is clicked, answer will change to true.
continueButton.setOnAction(e -> {
answer = true;
popWindow.close();
});
// New HBox layout with label.
HBox exitTopMenu = new HBox();
exitTopMenu.getChildren().add(label);
exitTopMenu.setAlignment(Pos.CENTER);
// New HBox layout with yes and no buttons.
HBox exitBottomMenu = new HBox();
exitBottomMenu.getChildren().addAll(continueButton);
exitBottomMenu.setAlignment(Pos.CENTER);
// New BorderPane, has label on the top and buttons on the bottom.
BorderPane borderPane = new BorderPane();
borderPane.setTop(exitTopMenu);
borderPane.setBottom(exitBottomMenu);
// Make a new scene.
Scene mainScene = new Scene(borderPane, 400, 100);
// Set the window scene to the main scene.
popWindow.setScene(mainScene);
// Show and wait for response.
popWindow.showAndWait();
// Returns the value of answer.
return answer;
}
}