Clear the method CreateMenu to make a new class with the same role
This commit is contained in:
		@ -64,7 +64,7 @@ public class Controller extends Application {
 | 
				
			|||||||
        //set up the page
 | 
					        //set up the page
 | 
				
			||||||
        stage = primaryStage;
 | 
					        stage = primaryStage;
 | 
				
			||||||
        stage.setTitle("ROAD TO MASTER YOU");
 | 
					        stage.setTitle("ROAD TO MASTER YOU");
 | 
				
			||||||
        Menu = createMenu();
 | 
					
 | 
				
			||||||
        Level_menu = createLevel_menu();
 | 
					        Level_menu = createLevel_menu();
 | 
				
			||||||
        Level_menu2 = createLevel_Menu2();
 | 
					        Level_menu2 = createLevel_Menu2();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -72,25 +72,7 @@ public class Controller extends Application {
 | 
				
			|||||||
        stage.show();
 | 
					        stage.show();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    private Scene createMenu(){
 | 
					 | 
				
			||||||
        Play = new Button("Play");
 | 
					 | 
				
			||||||
        Trophy = new Button("Trophy");
 | 
					 | 
				
			||||||
        Select_level = new Button("Select Level");
 | 
					 | 
				
			||||||
        Select_level.setOnAction(event -> switchScenes(Level_menu));
 | 
					 | 
				
			||||||
        title = new Label("Welcome to road to master you");
 | 
					 | 
				
			||||||
        title.setFont(Font.font(20));
 | 
					 | 
				
			||||||
        title.setTextFill(Color.GOLD);
 | 
					 | 
				
			||||||
        BdP = new BorderPane(null,title,Select_level,Trophy,Play);
 | 
					 | 
				
			||||||
        Menu = new Scene(BdP,700,400);
 | 
					 | 
				
			||||||
        BorderPane.setAlignment(title,Pos.CENTER);
 | 
					 | 
				
			||||||
        BorderPane.setAlignment(Play,Pos.CENTER);
 | 
					 | 
				
			||||||
        BorderPane.setAlignment(Select_level,Pos.CENTER);
 | 
					 | 
				
			||||||
        BorderPane.setAlignment(Trophy,Pos.CENTER);
 | 
					 | 
				
			||||||
        //Menu.getStylesheets().add("style.css"); todo creat a file css
 | 
					 | 
				
			||||||
        BdP.setPadding(new Insets(20,60,20,60));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return Menu;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    private Scene createLevel_menu(){
 | 
					    private Scene createLevel_menu(){
 | 
				
			||||||
        bck_menu = new Button("Back to the menu");
 | 
					        bck_menu = new Button("Back to the menu");
 | 
				
			||||||
        bck_menu.setOnAction(event -> switchScenes(Menu));
 | 
					        bck_menu.setOnAction(event -> switchScenes(Menu));
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										44
									
								
								app/src/main/java/school_project/MenuAcceuil.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								app/src/main/java/school_project/MenuAcceuil.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,44 @@
 | 
				
			|||||||
 | 
					package school_project;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javafx.geometry.Insets;
 | 
				
			||||||
 | 
					import javafx.geometry.Pos;
 | 
				
			||||||
 | 
					import javafx.scene.Scene;
 | 
				
			||||||
 | 
					import javafx.scene.control.Button;
 | 
				
			||||||
 | 
					import javafx.scene.control.Label;
 | 
				
			||||||
 | 
					import javafx.scene.layout.BorderPane;
 | 
				
			||||||
 | 
					import javafx.scene.layout.GridPane;
 | 
				
			||||||
 | 
					import javafx.scene.paint.Color;
 | 
				
			||||||
 | 
					import javafx.scene.text.Font;
 | 
				
			||||||
 | 
					import javafx.stage.Stage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class MenuAcceuil extends GridPane {
 | 
				
			||||||
 | 
					    private Button Play;
 | 
				
			||||||
 | 
					    private Button SelectLevel;
 | 
				
			||||||
 | 
					    private Button Trophy;
 | 
				
			||||||
 | 
					    private Scene scene;
 | 
				
			||||||
 | 
					    private BorderPane BdP;
 | 
				
			||||||
 | 
					    private Label Title;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public MenuAcceuil(){
 | 
				
			||||||
 | 
					        super();
 | 
				
			||||||
 | 
					        Play = new Button("Play");
 | 
				
			||||||
 | 
					        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);
 | 
				
			||||||
 | 
					        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);
 | 
				
			||||||
 | 
					        //Menu.getStylesheets().add("style.css"); todo creat a file css
 | 
				
			||||||
 | 
					        BdP.setPadding(new Insets(20,60,20,60));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -9,17 +9,16 @@ 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 Scene {
 | 
					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];
 | 
					    private 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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public MenuLevelDay1 (Parent root, int width, int height){
 | 
					    public MenuLevelDay1 (){
 | 
				
			||||||
        super(root,width,height);
 | 
					        super();
 | 
				
			||||||
        GridPane GdP = new GridPane();
 | 
					        GdP = new GridPane();
 | 
				
			||||||
        Level_menu = new Scene(GdP,700,400);
 | 
					 | 
				
			||||||
        //add all the button for level
 | 
					        //add all the button for level
 | 
				
			||||||
        Level_button[0] = new Button("1");
 | 
					        Level_button[0] = new Button("1");
 | 
				
			||||||
        Level_button[1] = new Button("2");
 | 
					        Level_button[1] = new Button("2");
 | 
				
			||||||
@ -49,6 +48,10 @@ public class MenuLevelDay1 extends Scene {
 | 
				
			|||||||
        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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user