Sub element from Controller to a new class

This commit is contained in:
Mat 2023-04-28 11:48:31 +02:00
parent 25a6782f3c
commit 075bdd9338
2 changed files with 54 additions and 32 deletions

View File

@ -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();

View File

@ -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);
}
}