1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
public JFXPanel start() throws Exception {
// Création du conteneur Swing pour JavaFX
JFXPanel fxPanel = new JFXPanel();
try{
// Localisation du fichier FXML.
URL url_fxml = getClass().getResource("IHM.fxml");
// Création du loader.
FXMLLoader fxmlLoader = new FXMLLoader(url_fxml);
// Chargement du FXML.
AnchorPane root = (AnchorPane) fxmlLoader.load();
// Création de la scène.
Scene scene = new Scene(root, 700, 600);
fxPanel.setScene(scene);
// Accès au controleur
// Controleur controleur = (Controleur) fxmlLoader.getController();
}catch(IOException ex) {
System.err.println("Erreur au chargement: " + ex);
}
return fxPanel;
} |