2
I’m passing a variable from window "A" to window "B". So far so good. The problem starts when in the "B" window I try to access the variable when the window starts. The value passed does not exist. Ex is 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 shows nothing. If you put a button and click print the variable already gives!
What am I doing wrong? How can I fix the problem?
Thank you Filipe, solved.
– Helder Pereira