Finishing MenuAcceuil

This commit is contained in:
Mat 2023-05-01 16:05:59 +02:00
parent 644af67a55
commit b4b89bcd86
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.Insets;
import javafx.geometry.Pos;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Menu;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import school_project.Menu.MenuAcceuil;
import school_project.Menu.MenuLevelDay1;
import school_project.Menu.MenuLevelDay2;
public class Controller extends Application {
private Stage stage;
Parent root;
public void start(Stage primaryStage) {
//set up the page
root = new MenuAcceuil();
stage = primaryStage;
stage.setTitle("ROAD TO MASTER YOU");
stage.setScene(new Scene(root));
stage.show();
}

View File

@ -11,9 +11,9 @@ import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.stage.Stage;
public class MenuAcceuil extends GridPane {
public class MenuAcceuil extends BorderPane {
private Button Play;
private Button SelectLevel;
public static Button SelectLevel;
private Button Trophy;
private Scene scene;
private BorderPane BdP;
@ -26,16 +26,18 @@ public class MenuAcceuil extends GridPane {
SelectLevel= new Button("Select Level");
Trophy = new Button("Trophy");
Title = new Label("Welcome to Road to Master");
BdP = new BorderPane(null,Title,SelectLevel,Trophy,Play);
scene = new Scene(BdP,700,400);
setTop(Title);
setLeft(Play);
setRight(SelectLevel);
setBottom(Trophy);
Title.setFont(Font.font(20));
Title.setTextFill(Color.GOLD);
BorderPane.setAlignment(Title, Pos.CENTER);
BorderPane.setAlignment(Play,Pos.CENTER);
BorderPane.setAlignment(SelectLevel,Pos.CENTER);
BorderPane.setAlignment(Trophy,Pos.CENTER);
setAlignment(Title, Pos.CENTER);
setAlignment(Play,Pos.CENTER);
setAlignment(SelectLevel,Pos.CENTER);
setAlignment(Trophy,Pos.CENTER);
//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
}

View File

@ -9,9 +9,12 @@ import javafx.scene.control.Button;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
import java.util.HashMap;
import java.util.Map;
public class MenuLevelDay1 extends GridPane {
//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
private Scene Level_menu;
private GridPane GdP;
@ -20,8 +23,13 @@ public class MenuLevelDay1 extends GridPane {
super();
GdP = new GridPane();
//add all the button for level
for (Button c : Level_button)
c = new Button((String(c+1)));
HashMap<String, Button> LevelButton = new HashMap<String, Button>();
/*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[1] = new Button("2");
@ -51,9 +59,9 @@ public class MenuLevelDay1 extends GridPane {
GdP.add(Level_button[9],1,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));;
//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[11], HPos.RIGHT);