From 8443e4d9dba74e207d66b696b0419c17543963f6 Mon Sep 17 00:00:00 2001
From: tmp1u19 <tmp1u19@soton.ac.uk>
Date: Thu, 12 Mar 2020 17:10:22 +0000
Subject: [PATCH] Class that keeps the alerts, scenes that have to appear
 whwnever an action occurs.

---
 Window.java | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 126 insertions(+)
 create mode 100644 Window.java

diff --git a/Window.java b/Window.java
new file mode 100644
index 0000000..4482a53
--- /dev/null
+++ b/Window.java
@@ -0,0 +1,126 @@
+import javafx.event.ActionEvent;
+import javafx.event.EventHandler;
+import javafx.geometry.Insets;
+import javafx.geometry.Pos;
+import javafx.scene.Scene;
+import javafx.scene.control.*;
+import javafx.scene.layout.VBox;
+import javafx.scene.text.Font;
+import javafx.stage.Modality;
+import javafx.stage.Stage;
+import javafx.stage.StageStyle;
+
+public class Window {
+
+    public void showButtons(Cell cell, int n) {
+
+        VBox menu = new VBox(10);
+        menu.setPadding(new Insets(10));
+        menu.setAlignment(Pos.TOP_LEFT);
+        menu.setStyle("-fx-background: rgb(201, 76, 76);");
+
+        Label message = new Label("Which one will you choose?");
+        message.setFont(Font.font(20));
+
+        menu.getChildren().add(message);
+
+        ToggleGroup toggle = new ToggleGroup();
+
+        for(int i = 0; i < n; i ++) {
+            RadioButton number = new RadioButton(String.valueOf(i + 1));
+            number.setFont(Font.font(20));
+            number.setToggleGroup(toggle);
+            menu.getChildren().add(number);
+        }
+
+        RadioButton delete = new RadioButton("Delete");
+        delete.setFont(Font.font(20));
+        delete.setToggleGroup(toggle);
+        menu.getChildren().add(delete);
+
+        Button choice = new Button("Choose");
+
+        choice.setFont(Font.font(20));
+        choice.setCancelButton(true);
+
+        menu.getChildren().add(choice);
+
+        Scene scene = new Scene(menu);
+        Stage inputButtons = new Stage();
+
+        choice.setOnAction(new EventHandler<ActionEvent>() {
+            @Override
+            public void handle(ActionEvent actionEvent) {
+                if(toggle.getSelectedToggle() != null) {
+
+                    RadioButton selectedRadioButton = (RadioButton) toggle.getSelectedToggle();
+
+                    if(selectedRadioButton.equals("Delete")) {
+                        cell.getTextField().clear();
+                    } else {
+                        cell.getTextField().setText(selectedRadioButton.getText());
+                    }
+
+                    inputButtons.close();
+                }
+            }
+        });
+
+        inputButtons.setScene(scene);
+        inputButtons.initStyle(StageStyle.UTILITY);
+        inputButtons.initModality(Modality.APPLICATION_MODAL);
+        inputButtons.setTitle("Button Control");
+        inputButtons.setMinWidth(300);
+        inputButtons.setMinHeight(370);
+
+        inputButtons.setX(400);
+        inputButtons.setY(400);
+
+        inputButtons.toFront();
+        inputButtons.show();
+    }
+
+    public void win(String message1, String message2) {
+
+        VBox menu = new VBox(5);
+        menu.setAlignment(Pos.TOP_CENTER);
+        menu.setStyle("-fx-background: pink;");
+
+        Label congrats = new Label(message1);
+        congrats.setFont(Font.font(35));
+        Label message = new Label(message2);
+        message.setFont(Font.font(25));
+
+        menu.getChildren().addAll(congrats, message);
+
+        Scene scene = new Scene(menu);
+
+        Stage winWindow = new Stage();
+        winWindow.setScene(scene);
+
+        winWindow.initStyle(StageStyle.UTILITY);
+        winWindow.initModality(Modality.APPLICATION_MODAL);
+        winWindow.setTitle("Game Won!");
+
+        winWindow.setMinHeight(150);
+        winWindow.setMinWidth(400);
+
+        winWindow.setX(800);
+        winWindow.setY(500);
+
+        winWindow.show();
+    }
+
+    public Alert getAlertDialog(String str) {
+
+        Alert alert = new Alert(Alert.AlertType.WARNING, str,
+                ButtonType.YES);
+        alert.setX(800);
+        alert.setY(400);
+        alert.setTitle("Confirmation of Action");
+        //alert.setHeaderText("Are you sure you want to clear the board?");
+        //alert.setContentText("Be aware that all your data will be cleared.");
+
+        return alert;
+    }
+}
-- 
GitLab