I have one parent controller which contain one button. When I click on button it open new window and show some data into table. The code I have used for opening window is >
In my example below, the account window (child/dialog) passes the newly selected account name back to the parent window when the save button is clicked. On the parent window ...
Stage nstage = new Stage();
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Accounts.fxml"));
Parent root = (Parent) fxmlLoader.load();
AccountsController accController = fxmlLoader.getController();
accController.dialogMode(); //Call a function in acconunt windoow to preset some fields
Scene scene = new Scene(root);
nstage.setTitle("Create Company Account");
nstage.setScene(scene);
Stage stage = (Stage) src.getScene().getWindow();
nstage.initOwner(stage);
nstage.initModality(Modality.APPLICATION_MODAL);
//nstage.initStyle(StageStyle.UNDECORATED);
nstage.show();
nstage.setOnCloseRequest(new EventHandler(){
public void handle(WindowEvent we) {
txtCompany.setText( accController.lbl1.getText() );
}
});