I am passing a variable from window "A" to window "B". So far so good. The problem starts when in window "B" I try to access the variable when the window starts. Past value does not exist. Ex. My code. Window "A"
FXMLLoader loader = new FXMLLoader();
AnchorPane root = loader.load(getClass().getResource("/gescomp/iniciarProva.fxml").openStream());
IniciarProvaController np = (IniciarProvaController) loader.getController();
Stage stage = new Stage();
stage.setTitle("Inicio");
stage.setScene(new Scene(root, 1000, 550));
stage.setResizable(false);
np.id = 33;
stage.show();
Window "B"
public int id;
@Override
public void initialize(URL url, ResourceBundle rb) {
System.out.println("<< " + id + " >>");
}
It should "print" 33, but it does not show anything. If you put a button and when you click to print the variable already gives!
What am I doing wrong? How can I fix the problem?