Finishing MenuAcceuil

This commit is contained in:
Mat 2023-05-01 16:05:59 +02:00 committed by Anthony Debucquoy
parent f41c073b41
commit 40eb5bd58a
Signed by: tonitch
GPG Key ID: A78D6421F083D42E
3 changed files with 32 additions and 15 deletions

View File

@ -4,27 +4,34 @@ import javafx.application.Application;
import javafx.geometry.HPos; import javafx.geometry.HPos;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.geometry.Pos; import javafx.geometry.Pos;
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.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.Menu;
import javafx.scene.layout.BorderPane; import javafx.scene.layout.BorderPane;
import javafx.scene.layout.ColumnConstraints; import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import javafx.scene.text.Font; import javafx.scene.text.Font;
import javafx.stage.Stage; import javafx.stage.Stage;
import school_project.Menu.MenuAcceuil;
import school_project.Menu.MenuLevelDay1;
import school_project.Menu.MenuLevelDay2;
public class Controller extends Application { public class Controller extends Application {
private Stage stage; private Stage stage;
Parent root;
public void start(Stage primaryStage) { public void start(Stage primaryStage) {
//set up the page //set up the page
root = new MenuAcceuil();
stage = primaryStage; stage = primaryStage;
stage.setTitle("ROAD TO MASTER YOU"); stage.setTitle("ROAD TO MASTER YOU");
stage.setScene(new Scene(root));
stage.show(); stage.show();
} }

View File

@ -11,9 +11,9 @@ import javafx.scene.paint.Color;
import javafx.scene.text.Font; import javafx.scene.text.Font;
import javafx.stage.Stage; import javafx.stage.Stage;
public class MenuAcceuil extends GridPane { public class MenuAcceuil extends BorderPane {
private Button Play; private Button Play;
private Button SelectLevel; public static Button SelectLevel;
private Button Trophy; private Button Trophy;
private Scene scene; private Scene scene;
private BorderPane BdP; private BorderPane BdP;
@ -26,16 +26,18 @@ public class MenuAcceuil extends GridPane {
SelectLevel= new Button("Select Level"); SelectLevel= new Button("Select Level");
Trophy = new Button("Trophy"); Trophy = new Button("Trophy");
Title = new Label("Welcome to Road to Master"); Title = new Label("Welcome to Road to Master");
BdP = new BorderPane(null,Title,SelectLevel,Trophy,Play); setTop(Title);
scene = new Scene(BdP,700,400); setLeft(Play);
setRight(SelectLevel);
setBottom(Trophy);
Title.setFont(Font.font(20)); Title.setFont(Font.font(20));
Title.setTextFill(Color.GOLD); Title.setTextFill(Color.GOLD);
BorderPane.setAlignment(Title, Pos.CENTER); setAlignment(Title, Pos.CENTER);
BorderPane.setAlignment(Play,Pos.CENTER); setAlignment(Play,Pos.CENTER);
BorderPane.setAlignment(SelectLevel,Pos.CENTER); setAlignment(SelectLevel,Pos.CENTER);
BorderPane.setAlignment(Trophy,Pos.CENTER); setAlignment(Trophy,Pos.CENTER);
//Menu.getStylesheets().add("style.css"); todo creat a file css //Menu.getStylesheets().add("style.css"); todo creat a file css
BdP.setPadding(new Insets(20,60,20,60)); setPadding(new Insets(20,60,20,60));
//need help to add MenuAcceuil //need help to add MenuAcceuil
} }

View File

@ -9,9 +9,12 @@ 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;
import java.util.HashMap;
import java.util.Map;
public class MenuLevelDay1 extends GridPane { public class MenuLevelDay1 extends GridPane {
//set up all object for the scene //set up all object for the scene
private Button[] Level_button = new Button[13]; public static Button[] Level_button = new Button[13];
//set up the scene //set up the scene
private Scene Level_menu; private Scene Level_menu;
private GridPane GdP; private GridPane GdP;
@ -20,8 +23,13 @@ public class MenuLevelDay1 extends GridPane {
super(); super();
GdP = new GridPane(); GdP = new GridPane();
//add all the button for level //add all the button for level
for (Button c : Level_button) HashMap<String, Button> LevelButton = new HashMap<String, Button>();
c = new Button((String(c+1)));
/*for (Map.Entry<String,Button> c : LevelButton) {
c.setValue(new Button());
required: array or java.lang.Iterable
found: HashMap<String,Button>
}*/
Level_button[0] = new Button("1"); Level_button[0] = new Button("1");
Level_button[1] = new Button("2"); Level_button[1] = new Button("2");
@ -51,9 +59,9 @@ public class MenuLevelDay1 extends GridPane {
GdP.add(Level_button[9],1,4); GdP.add(Level_button[9],1,4);
GdP.add(Level_button[12],2,4); GdP.add(Level_button[12],2,4);
for( int i= 0;i<=9;i++); /***for( int i= 0;i<=9;i++);
GridPane.setHalignment((Level_button[i],HPos.CENTER));; GridPane.setHalignment((Level_button[i],HPos.CENTER));;
//todo understand why it doesn't work //todo understand why it doesn't work**/
GridPane.setHalignment(Level_button[10], HPos.LEFT); GridPane.setHalignment(Level_button[10], HPos.LEFT);
GridPane.setHalignment(Level_button[11], HPos.RIGHT); GridPane.setHalignment(Level_button[11], HPos.RIGHT);