From 2f99644369756180ea117cc5b3c49b11e2298e2c Mon Sep 17 00:00:00 2001 From: Chiara Date: Fri, 17 Apr 2020 15:16:08 +0200 Subject: [PATCH] changement qui marche --- src/ihm/FxmlLoader.java | 25 --------------------- src/ihm/controller/MenuController.java | 31 +++++++++++++++++--------- src/ihm/ressources/Menu.fxml | 3 +-- 3 files changed, 22 insertions(+), 37 deletions(-) delete mode 100644 src/ihm/FxmlLoader.java diff --git a/src/ihm/FxmlLoader.java b/src/ihm/FxmlLoader.java deleted file mode 100644 index d746e1b..0000000 --- a/src/ihm/FxmlLoader.java +++ /dev/null @@ -1,25 +0,0 @@ -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 0a060de..5eb3801 100644 --- a/src/ihm/controller/MenuController.java +++ b/src/ihm/controller/MenuController.java @@ -1,22 +1,33 @@ package ihm.controller; -import ihm.FxmlLoader; +import java.io.IOException; +import java.net.URL; +import java.util.ResourceBundle; + import javafx.fxml.FXML; -import javafx.scene.Scene; -import javafx.scene.control.Label; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; import javafx.scene.input.MouseEvent; +import javafx.scene.layout.BorderPane; import javafx.scene.layout.Pane; import javafx.stage.Stage; -public class MenuController { - private Stage window; +public class MenuController implements Initializable{ + @FXML + private Pane rootPane; + + @Override + public void initialize(URL arg0, ResourceBundle arg1) { + // TODO Auto-generated method stub + + } - public void commencerPartie(MouseEvent mouseEvent) { + @FXML + public void commencerPartie(MouseEvent mouseEvent) throws IOException{ System.out.println("Bonjouuuuur!"); - FxmlLoader object = new FxmlLoader(); - Pane view = object.getPage("Choix_joueur"); - Scene scene = new Scene(view); - window.setScene(scene); + BorderPane pane = FXMLLoader.load(getClass().getResource("../ressources/Choix_joueur.fxml")); + System.out.println(rootPane); + rootPane.getChildren().setAll(pane); } public void afficherRegle(MouseEvent mouseEvent) { diff --git a/src/ihm/ressources/Menu.fxml b/src/ihm/ressources/Menu.fxml index f9985dd..cdd52ed 100644 --- a/src/ihm/ressources/Menu.fxml +++ b/src/ihm/ressources/Menu.fxml @@ -5,8 +5,7 @@ - - +