Yes, i saw this answer Passing Parameters JavaFX FXML. But it's not working.
setDayParting
works from Controller Nº1 but when i'm call updatePreview
in Controller Nº2 the parameter what i passed is not there.
Why this don't work?
Passing parameters in Controller Nº1:
private void giveParameterToController() { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(Main.newFileScreenFile)); NewFileScreenController newFileScreenController; try { Pane pane = fxmlLoader.load(); newFileScreenController = fxmlLoader.getController(); newFileScreenController.setDayParting("Working"); myController.setScreen(Main.newFileScreen); } catch (IOException e) { e.printStackTrace(); } }
Controller Nº2:
public void setDayParting(String parting){ dayParting = parting; System.out.println(dayParting); } private void updatePreview(){ System.out.println(dayParting); }
output:
Working
null