diff --git a/bin/coursework/Main.class b/bin/coursework/Main.class index 464a8a449899abc71b6193a9814592f925eb09f1..a39cec4c4f4e11a238935119c5608bbb268a410f 100644 Binary files a/bin/coursework/Main.class and b/bin/coursework/Main.class differ diff --git a/src/coursework/Main.java b/src/coursework/Main.java index c9b219c41255d85057c0c131ff6191af9ba9bf28..c2a2f03961f199297dca350b27365553576b9a7a 100644 --- a/src/coursework/Main.java +++ b/src/coursework/Main.java @@ -30,6 +30,7 @@ import javafx.scene.control.ToggleGroup; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.input.MouseEvent; +import javafx.scene.layout.BorderPane; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; @@ -278,7 +279,7 @@ public class Main extends Application { vbox.getChildren().add(balanceButtonBottom); vbox.setSpacing(10); vbox.setAlignment(Pos.CENTER_LEFT); - vbox.setPadding(new Insets(0, 0, 0, 0)); + vbox.setPadding(new Insets(10)); return vbox; } @@ -287,6 +288,7 @@ public class Main extends Application { vbox.getChildren().addAll(setupButton("Tiny", 10, 71), setupButton("Small", 14, 81), setupButton("Medium", 18, 91), setupButton("Large", 22, 101), setupButton("Huge", 26, 111)); vbox.setSpacing(15); vbox.setAlignment(Pos.CENTER); + vbox.setPadding(new Insets(10)); return vbox; } @@ -741,64 +743,31 @@ public class Main extends Application { @Override public void start(Stage primaryStage) throws Exception { stage = primaryStage; - VBox vBox = new VBox(); + BorderPane borderPane = new BorderPane(); int width = 350 + 80 * N; int height = 275 + 80 * N; - scene = new Scene(vBox, width, height); + scene = new Scene(borderPane, width, height); stage.setWidth(width); stage.setHeight(height); - vBox.setSpacing(5); - vBox.setPadding(new Insets(20)); - vBox.setAlignment(Pos.CENTER); + borderPane.setPadding(new Insets(20)); GridPane gridPane = setupGrid(width - 200, height - 175); undoStack.push(new GameState(GameState.getCurrentGameState(gridNumbers))); fontSize = 18; changeFontSizeEvent(fontSize); - HBox topHBox = setupTopHBox(); + HBox topHBox = setupTopHBox(); VBox fontSizeVBox = setupFontSizeHBox(); VBox numbersVBox = setupNumbersVBox(); - HBox gridHBox = new HBox(); - gridHBox.getChildren().addAll(fontSizeVBox, gridPane, numbersVBox); - gridHBox.setSpacing(10); - gridHBox.setAlignment(Pos.CENTER); - HBox bottomHBox = setupBottomHBox(); - ///// -// Button tempButton = new Button("SHOW ANSWER"); -// int[] answers = {5,6,3,4,1,2,6,1,4,5,2,3,4,5,2,3,6,1,3,4,1,2,5,6,2,3,6,1,4,5,1,2,5,6,3,4}; -// tempButton.setOnAction(e -> { -// if (N != 6) { -// Animation animation = new Animation(); -// animation.go(); -// } -// else { -// BufferedReader file; -// try { -// file = new BufferedReader(new FileReader(new File("C:\\Java Eclipse Workspace\\Programming II Coursework\\mathdokuCage.txt"))); -// -// String line; -// while ((line = file.readLine()) != null) { -// createNewCage(line); -// } -// file.close(); -// -// for (int i = 0; i < gridNumbers.length; i++) { -// gridNumbers[i].setText(answers[i] + ""); -// } -// } -// catch (IOException ex) { -// System.err.println(ex); -// } -// } -// }); - ///// - - vBox.getChildren().addAll(topHBox, gridHBox, bottomHBox); + borderPane.setTop(topHBox); + borderPane.setLeft(fontSizeVBox); + borderPane.setRight(numbersVBox); + borderPane.setBottom(bottomHBox); + borderPane.setCenter(gridPane); stageWidthResizeEvent(stage, gridPane); stageHeightResizeEvent(stage, gridPane); @@ -814,35 +783,32 @@ public class Main extends Application { private void resetGrid() { stage.close(); initialiseVariables(); - VBox vBox = new VBox(); + BorderPane borderPane = new BorderPane();; int width = 350 + 80 * N; int height = 275 + 80 * N; Stage newStage = new Stage(); - Scene newScene = new Scene(vBox, width, height); + Scene newScene = new Scene(borderPane, width, height); newStage.setWidth(width); newStage.setHeight(height); - vBox.setSpacing(5); - vBox.setPadding(new Insets(20)); - vBox.setAlignment(Pos.CENTER); + borderPane.setPadding(new Insets(20)); GridPane gridPane = setupGrid(width - 200, height - 175); undoStack.push(new GameState(GameState.getCurrentGameState(gridNumbers))); fontSize = 18; changeFontSizeEvent(fontSize); - HBox topHBox = setupTopHBox(); + HBox topHBox = setupTopHBox(); VBox fontSizeVBox = setupFontSizeHBox(); VBox numbersVBox = setupNumbersVBox(); - HBox gridHBox = new HBox(); - gridHBox.getChildren().addAll(fontSizeVBox, gridPane, numbersVBox); - gridHBox.setSpacing(10); - gridHBox.setAlignment(Pos.CENTER); - HBox bottomHBox = setupBottomHBox(); - vBox.getChildren().addAll(topHBox, gridHBox, bottomHBox); + borderPane.setTop(topHBox); + borderPane.setLeft(fontSizeVBox); + borderPane.setRight(numbersVBox); + borderPane.setBottom(bottomHBox); + borderPane.setCenter(gridPane); stageWidthResizeEvent(stage, gridPane); stageHeightResizeEvent(stage, gridPane);