Skip to content
Snippets Groups Projects
Commit 894b3540 authored by Nimrod Abramovich's avatar Nimrod Abramovich
Browse files

changed highest node to border pane

parent 8903b8c5
No related branches found
No related tags found
No related merge requests found
No preview for this file type
...@@ -30,6 +30,7 @@ import javafx.scene.control.ToggleGroup; ...@@ -30,6 +30,7 @@ import javafx.scene.control.ToggleGroup;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent; import javafx.scene.input.MouseEvent;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane; import javafx.scene.layout.Pane;
...@@ -278,7 +279,7 @@ public class Main extends Application { ...@@ -278,7 +279,7 @@ public class Main extends Application {
vbox.getChildren().add(balanceButtonBottom); vbox.getChildren().add(balanceButtonBottom);
vbox.setSpacing(10); vbox.setSpacing(10);
vbox.setAlignment(Pos.CENTER_LEFT); vbox.setAlignment(Pos.CENTER_LEFT);
vbox.setPadding(new Insets(0, 0, 0, 0)); vbox.setPadding(new Insets(10));
return vbox; return vbox;
} }
...@@ -287,6 +288,7 @@ public class Main extends Application { ...@@ -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.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.setSpacing(15);
vbox.setAlignment(Pos.CENTER); vbox.setAlignment(Pos.CENTER);
vbox.setPadding(new Insets(10));
return vbox; return vbox;
} }
...@@ -741,64 +743,31 @@ public class Main extends Application { ...@@ -741,64 +743,31 @@ public class Main extends Application {
@Override @Override
public void start(Stage primaryStage) throws Exception { public void start(Stage primaryStage) throws Exception {
stage = primaryStage; stage = primaryStage;
VBox vBox = new VBox(); BorderPane borderPane = new BorderPane();
int width = 350 + 80 * N; int width = 350 + 80 * N;
int height = 275 + 80 * N; int height = 275 + 80 * N;
scene = new Scene(vBox, width, height); scene = new Scene(borderPane, width, height);
stage.setWidth(width); stage.setWidth(width);
stage.setHeight(height); stage.setHeight(height);
vBox.setSpacing(5); borderPane.setPadding(new Insets(20));
vBox.setPadding(new Insets(20));
vBox.setAlignment(Pos.CENTER);
GridPane gridPane = setupGrid(width - 200, height - 175); GridPane gridPane = setupGrid(width - 200, height - 175);
undoStack.push(new GameState(GameState.getCurrentGameState(gridNumbers))); undoStack.push(new GameState(GameState.getCurrentGameState(gridNumbers)));
fontSize = 18; fontSize = 18;
changeFontSizeEvent(fontSize); changeFontSizeEvent(fontSize);
HBox topHBox = setupTopHBox();
HBox topHBox = setupTopHBox();
VBox fontSizeVBox = setupFontSizeHBox(); VBox fontSizeVBox = setupFontSizeHBox();
VBox numbersVBox = setupNumbersVBox(); VBox numbersVBox = setupNumbersVBox();
HBox gridHBox = new HBox();
gridHBox.getChildren().addAll(fontSizeVBox, gridPane, numbersVBox);
gridHBox.setSpacing(10);
gridHBox.setAlignment(Pos.CENTER);
HBox bottomHBox = setupBottomHBox(); HBox bottomHBox = setupBottomHBox();
///// borderPane.setTop(topHBox);
// Button tempButton = new Button("SHOW ANSWER"); borderPane.setLeft(fontSizeVBox);
// 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}; borderPane.setRight(numbersVBox);
// tempButton.setOnAction(e -> { borderPane.setBottom(bottomHBox);
// if (N != 6) { borderPane.setCenter(gridPane);
// 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);
stageWidthResizeEvent(stage, gridPane); stageWidthResizeEvent(stage, gridPane);
stageHeightResizeEvent(stage, gridPane); stageHeightResizeEvent(stage, gridPane);
...@@ -814,35 +783,32 @@ public class Main extends Application { ...@@ -814,35 +783,32 @@ public class Main extends Application {
private void resetGrid() { private void resetGrid() {
stage.close(); stage.close();
initialiseVariables(); initialiseVariables();
VBox vBox = new VBox(); BorderPane borderPane = new BorderPane();;
int width = 350 + 80 * N; int width = 350 + 80 * N;
int height = 275 + 80 * N; int height = 275 + 80 * N;
Stage newStage = new Stage(); Stage newStage = new Stage();
Scene newScene = new Scene(vBox, width, height); Scene newScene = new Scene(borderPane, width, height);
newStage.setWidth(width); newStage.setWidth(width);
newStage.setHeight(height); newStage.setHeight(height);
vBox.setSpacing(5); borderPane.setPadding(new Insets(20));
vBox.setPadding(new Insets(20));
vBox.setAlignment(Pos.CENTER);
GridPane gridPane = setupGrid(width - 200, height - 175); GridPane gridPane = setupGrid(width - 200, height - 175);
undoStack.push(new GameState(GameState.getCurrentGameState(gridNumbers))); undoStack.push(new GameState(GameState.getCurrentGameState(gridNumbers)));
fontSize = 18; fontSize = 18;
changeFontSizeEvent(fontSize); changeFontSizeEvent(fontSize);
HBox topHBox = setupTopHBox();
HBox topHBox = setupTopHBox();
VBox fontSizeVBox = setupFontSizeHBox(); VBox fontSizeVBox = setupFontSizeHBox();
VBox numbersVBox = setupNumbersVBox(); VBox numbersVBox = setupNumbersVBox();
HBox gridHBox = new HBox();
gridHBox.getChildren().addAll(fontSizeVBox, gridPane, numbersVBox);
gridHBox.setSpacing(10);
gridHBox.setAlignment(Pos.CENTER);
HBox bottomHBox = setupBottomHBox(); 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); stageWidthResizeEvent(stage, gridPane);
stageHeightResizeEvent(stage, gridPane); stageHeightResizeEvent(stage, gridPane);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment