I'm calling a method to load a window by passing some parameters to a specific internal method of this window, but I've got this exception:
GRAVE: null
javafx.fxml.LoadException: Controller value already specified.
unknown path:12
here is my method
public void openDef(String sys, String comp, String code) throws Exception {
Stage defStage = new Stage();
FXMLLoader loader = new FXMLLoader();
DefTableController cont = new DefTableController();//calling class controller
loader.setController(cont);
Parent frame = loader.load(getClass().getResource("defTable.fxml").openStream());
cont.getSysChoice(sys, comp, code);//call the method by passing parameters
Scene sceneDef = new Scene(frame);
defStage.setTitle("Défaillance du " + comp);
defStage.setScene(sceneDef);
defStage.show();
}
I don't understand why it consider that the controller is already set? and how to fix that ? thank you
Remove the fx:controller attribute from the FXML file. That attribute is an instruction to the FXMLLoader to create a new controller: since you have already set one by calling setController it is contradictory.
JavaFX Error: Controller value already specified
This guy answered it ^ Props to him!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With