Make an array for buttons and add a constructor

This commit is contained in:
Mat 2023-04-28 12:01:30 +02:00 committed by Anthony Debucquoy
parent c0f8871487
commit dd76f4c0df
Signed by: tonitch
GPG Key ID: A78D6421F083D42E

View File

@ -2,38 +2,38 @@ package school_project;
import javafx.geometry.HPos; import javafx.geometry.HPos;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.layout.ColumnConstraints; import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
public class MenuLevelDay1 extends Controller { public class MenuLevelDay1 extends Scene {
//set up all object for the scene //set up all object for the scene
private Button Day_2; private Button[] Level_button = new Button[13];
private Button Day_3;
private Button[] Level_button = new Button[10];
//set up the scene //set up the scene
private Scene Level_menu; private Scene Level_menu;
private GridPane GdP; private GridPane GdP;
private Button bck_menu;
private Scene createLevel_menu(){ public MenuLevelDay1 (Parent root, int width, int height){
super(root,width,height);
GridPane GdP = new GridPane(); GridPane GdP = new GridPane();
Level_menu = new Scene(GdP,700,400); Level_menu = new Scene(GdP,700,400);
//add all the button for level //add all the button for level
_1 = new Button("1"); Level_button[0] = new Button("1");
_2 = new Button("2"); Level_button[1] = new Button("2");
_3 = new Button("3"); Level_button[2]= new Button("3");
_4 = new Button("4"); Level_button[3]= new Button("4");
_5 = new Button("5"); Level_button[4] = new Button("5");
_6 = new Button("6"); Level_button[5]= new Button("6");
_7 = new Button("7"); Level_button[6] = new Button("7");
_8 = new Button("8"); Level_button[7] = new Button("8");
_9 = new Button("9"); Level_button[8] = new Button("9");
_10 = new Button("10"); Level_button[9] = new Button("10");
Day_2 = new Button("Day 2"); Level_button[10] = new Button("Day 2");
Day_3 = new Button("Day 3"); Level_button[11] = new Button("Day 3");
bck_menu = new Button("Back to menu"); Level_button[12] = new Button("Back to menu");
//add to the good position in gridpane all the button //add to the good position in gridpane all the button
GdP.add(Day_2,1,0); GdP.add(Day_2,1,0);
GdP.add(Day_3,1,0); GdP.add(Day_3,1,0);