I need to pass a Stage to my Filechooser in the Controller Class.
For that I need to set a Controller in my MainDesignClass.
What is wrong here:
@Override
public void start( Stage primaryStage) throws Exception{
FXMLLoader loader= new FXMLLoader(getClass().getResources("myfxml.fxml");
Parent root =(Parent)loader.load();
primaryStage = new Stage();
Controller myController=loader.getController();
myController.setStage(primaryStage);
primaryStage.setTitle("myapp");
primaryStage.getIcons().add(image);
primaryStage.setScene(new Scene(root,900,600));
primaryStage.show();
}
setStage is marked red. But why? Why it cannot find the method? How can I use FileChooser then in my Controller.class ?