Return value from stage


Question

In javaFX i open a new stage by this code:

    Parent root2 ;
    root2 = FXMLLoader.load(getClass().getResource("FXMLelencoSoci.fxml"));
    Scene scena = new Scene(root2, 800, 800);
    final Stage stage2 = new Stage();
    stage2.initStyle(StageStyle.UNDECORATED);
    stage2.initModality(Modality.WINDOW_MODAL);
    stage2.initOwner(((Node) event.getSource()).getScene().getWindow());
    stage2.setScene(scena);
    stage2.show();

this display a table with 2 colums code(int) and name(string) How can i obtain from the caller Stage the value of the code selected in the table? Thanks

1
0
9/23/2013 11:24:18 AM

here is a solution... posibly not the best one... You could use the UserData of the root2. from the controller of the FXMLelencoSoci, set the user data to the main pane of it. This you can achive it by doing the followin:

mainPane.setUserData(value);

and from the main stage, you know this pane as root2, so use this:

value = root2.getUserData();

That would be the way that you want... But I would make the two controllers know each other, so that you can still use the Tiped references.

2
9/23/2013 8:27:57 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon