From 075bdd933887f7729d18882b9c9fb0db2d9a5127 Mon Sep 17 00:00:00 2001 From: Mat Date: Fri, 28 Apr 2023 11:48:31 +0200 Subject: [PATCH] Sub element from Controller to a new class --- .../main/java/school_project/Controller.java | 32 ----------- .../java/school_project/MenuLevelDay1.java | 54 +++++++++++++++++++ 2 files changed, 54 insertions(+), 32 deletions(-) create mode 100644 app/src/main/java/school_project/MenuLevelDay1.java diff --git a/app/src/main/java/school_project/Controller.java b/app/src/main/java/school_project/Controller.java index a51d5b0..00da21d 100644 --- a/app/src/main/java/school_project/Controller.java +++ b/app/src/main/java/school_project/Controller.java @@ -94,39 +94,7 @@ public class Controller extends Application { private Scene createLevel_menu(){ bck_menu = new Button("Back to the menu"); bck_menu.setOnAction(event -> switchScenes(Menu)); - GdP = new GridPane(); - Level_menu = new Scene(GdP,700,400); - _1 = new Button("1"); - _2 = new Button("2"); - _3 = new Button("3"); - _4 = new Button("4"); - _5 = new Button("5"); - _6 = new Button("6"); - _7 = new Button("7"); - _8 = new Button("8"); - _9 = new Button("9"); - _10 = new Button("10"); - Day_2 = new Button("Day 2"); - Day_3 = new Button("Day 3"); - //set up of the button - GdP.add(Day_2,1,0); - GdP.add(Day_3,1,0); - GdP.add(_1,0,1); - GdP.add(_2,1,1); - GdP.add(_3,2,1); - GdP.add(_4,0,2); - GdP.add(_5,1,2); - GdP.add(_6,2,2); - GdP.add(_7,0,3); - GdP.add(_8,1,3); - GdP.add(_9,2,3); - GdP.add(_10,1,4); - GdP.add(bck_menu,2,4); - //set up gap and padding and everything else - GdP.setHgap(20); - GdP.setVgap(20); - GdP.setPadding(new Insets(40,20,20,40)); ColumnConstraints col_1 = new ColumnConstraints(); col_1.setPercentWidth(33); ColumnConstraints col_2 = new ColumnConstraints(); diff --git a/app/src/main/java/school_project/MenuLevelDay1.java b/app/src/main/java/school_project/MenuLevelDay1.java new file mode 100644 index 0000000..60313c0 --- /dev/null +++ b/app/src/main/java/school_project/MenuLevelDay1.java @@ -0,0 +1,54 @@ +package school_project; + +import javafx.geometry.HPos; +import javafx.geometry.Insets; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.layout.ColumnConstraints; +import javafx.scene.layout.GridPane; + +public class MenuLevelDay1 extends Controller { + //set up all object for the scene + private Button Day_2; + private Button Day_3; + private Button[] Level_button = new Button[10]; + //set up the scene + private Scene Level_menu; + private GridPane GdP; + private Button bck_menu; + + private Scene createLevel_menu(){ + GridPane GdP = new GridPane(); + Level_menu = new Scene(GdP,700,400); + //add all the button for level + _1 = new Button("1"); + _2 = new Button("2"); + _3 = new Button("3"); + _4 = new Button("4"); + _5 = new Button("5"); + _6 = new Button("6"); + _7 = new Button("7"); + _8 = new Button("8"); + _9 = new Button("9"); + _10 = new Button("10"); + Day_2 = new Button("Day 2"); + Day_3 = new Button("Day 3"); + bck_menu = new Button("Back to menu"); + //add to the good position in gridpane all the button + GdP.add(Day_2,1,0); + GdP.add(Day_3,1,0); + GdP.add(_1,0,1); + GdP.add(_2,1,1); + GdP.add(_3,2,1); + GdP.add(_4,0,2); + GdP.add(_5,1,2); + GdP.add(_6,2,2); + GdP.add(_7,0,3); + GdP.add(_8,1,3); + GdP.add(_9,2,3); + GdP.add(_10,1,4); + GdP.add(bck_menu,2,4); + + } + +}