diff --git a/src/ihm/FxmlLoader.java b/src/ihm/FxmlLoader.java new file mode 100644 index 0000000..d746e1b --- /dev/null +++ b/src/ihm/FxmlLoader.java @@ -0,0 +1,25 @@ +package ihm; + +import java.io.FileNotFoundException; +import java.net.URL; + +import javafx.fxml.FXMLLoader; +import javafx.scene.layout.Pane; + +public class FxmlLoader { + private Pane view; + + public Pane getPage(String fileName) { + try { + URL fileUrl = Main.class.getResource("ressources/" + fileName + ".fxml"); + if (fileUrl == null) { + throw new FileNotFoundException("Fil fxml pas trouvé"); + } + + view = new FXMLLoader().load(fileUrl); + }catch (Exception e) { + System.out.println("Pas de file" + fileName); + } + return view; + } +} diff --git a/src/ihm/controller/MenuController.java b/src/ihm/controller/MenuController.java index c225b95..0a060de 100644 --- a/src/ihm/controller/MenuController.java +++ b/src/ihm/controller/MenuController.java @@ -1,26 +1,25 @@ package ihm.controller; +import ihm.FxmlLoader; import javafx.fxml.FXML; +import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.input.MouseEvent; +import javafx.scene.layout.Pane; +import javafx.stage.Stage; public class MenuController { - @FXML - private Label label; + private Stage window; -<<<<<<< HEAD - public void commencerPartie(MouseEvent mouseEvent) { + public void commencerPartie(MouseEvent mouseEvent) { System.out.println("Bonjouuuuur!"); + FxmlLoader object = new FxmlLoader(); + Pane view = object.getPage("Choix_joueur"); + Scene scene = new Scene(view); + window.setScene(scene); } public void afficherRegle(MouseEvent mouseEvent) { -======= - public void afficheBonjour(MouseEvent mouseEvent) { - System.out.println("Bonjouuuuur!"); - } - - public void changerNom(MouseEvent mouseEvent) { ->>>>>>> 88af99848491a78118cac6121fa65e6c2ffd3f56 - System.out.println("clik"); + System.out.println("blaaaa"); } } diff --git a/src/ihm/ressources/Menu.fxml b/src/ihm/ressources/Menu.fxml index d36db48..f9985dd 100644 --- a/src/ihm/ressources/Menu.fxml +++ b/src/ihm/ressources/Menu.fxml @@ -5,30 +5,23 @@ - + + -<<<<<<< HEAD - -<<<<<<< HEAD - - + +