How can I pass a parameter to the controller from Application in the start method?
start method:
public void start(Stage primaryStage) throws Exception { FXMLLoader loader = new FXMLLoader(getClass().getResource("windows/userTestWindow.fxml")); Parent root = loader.load(); UserTestController controller = loader.getController(); controller.setStage(primaryStage); primaryStage.setTitle("TESTOsteron - Тест"); primaryStage.setScene(new Scene(root)); primaryStage.setMaximized(true); primaryStage.setMinWidth(MIN_WIDTH); primaryStage.setMinHeight(MIN_HEIGHT); primaryStage.getIcons().add(icon); //controller.setTestKod(testKod); primaryStage.show(); }
tried to pass through
controller.setTestKod(testKod);
that is, the controller has such a method and the testKod field, but nothing is transmitted, testKod is still 0. I just do not understand why the Stage is then transmitted in this way to the controller, but a simple parameter cannot.