From 2e34cb91b4a90d79781c2e6a3873057527e9fc03 Mon Sep 17 00:00:00 2001 From: cemal Date: Wed, 18 May 2022 10:24:18 +0200 Subject: [PATCH] working main screen --- .../application/LaticeApplicationWindow.java | 14 ++++++++++---- .../latice/controller/MainScreenController.java | 9 +++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/java/latice/application/LaticeApplicationWindow.java b/src/main/java/latice/application/LaticeApplicationWindow.java index 870fa10..6ce8baa 100644 --- a/src/main/java/latice/application/LaticeApplicationWindow.java +++ b/src/main/java/latice/application/LaticeApplicationWindow.java @@ -58,6 +58,7 @@ public class LaticeApplicationWindow extends Application { ArrayList listTileImage = Rack.getRackTileImage(); ArrayList listOfTile = new ArrayList(); Map assocRectangleTile = new HashMap(); + static BorderPane rootLayout; public static int indexTileClicked; @@ -261,8 +262,7 @@ public class LaticeApplicationWindow extends Application { //-------------------------------------------------------------------------------------- - - Scene scene = new Scene(root, 1280, 720); + setRootLayout(root); primaryStage.setResizable(false); primaryStage.setTitle("Latice"); @@ -270,8 +270,12 @@ public class LaticeApplicationWindow extends Application { primaryStage.show(); } - - + public static void setRootLayout(BorderPane root) { + rootLayout = root; + } + public static BorderPane getRootLayout() { + return rootLayout; + } @@ -288,5 +292,7 @@ public class LaticeApplicationWindow extends Application { public static void setIndexTileClicked(int indexTileClicked) { LaticeApplicationWindow.indexTileClicked = indexTileClicked; } + + } diff --git a/src/main/java/latice/controller/MainScreenController.java b/src/main/java/latice/controller/MainScreenController.java index dfc0ab2..c49baf5 100644 --- a/src/main/java/latice/controller/MainScreenController.java +++ b/src/main/java/latice/controller/MainScreenController.java @@ -2,10 +2,12 @@ package latice.controller; import javafx.application.Platform; import javafx.fxml.FXML; +import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.input.MouseEvent; - +import javafx.scene.layout.BorderPane; import javafx.scene.shape.Rectangle; +import javafx.stage.Stage; import latice.application.LaticeApplicationWindow; public class MainScreenController extends LaticeApplicationWindow{ @@ -20,7 +22,10 @@ public class MainScreenController extends LaticeApplicationWindow{ @FXML public void playButtonClicked(MouseEvent event) { System.out.println("playButtonClicked"); - + Stage stage = (Stage) ((Node) event.getTarget()).getScene().getWindow(); + BorderPane root = getRootLayout(); + Scene scene = new Scene(root, 1280, 720); + stage.setScene(scene); } // Event Listener on Rectangle[#rulesButton].onMouseClicked @FXML