I have three controllers, one that holds my Boderpane component CrechHome
that switches between views, and another that has a button where my code resides EnfantController
, and one where I need that button to direct me PaymentController
I need that button to do something in the scene I'm in and then show another view (Payment
), for that I'm loading my CrechHome
controller so I can get the borderPane instance to switch to the other view, but the the following does nothing (I'm still in the same view as before) and shows no error.
Here's the code:
public class EnfantController implements Initializable {
@FXML
private Button payement;
@FXML
private void payementEnf(ActionEvent event) throws IOException {
// get the crechHomeController to get the borderPane
FXMLLoader loader2 = new FXMLLoader();
loader2.setLocation(getClass().getResource("/Views/CrechHome.fxml"));
Node node2 = loader2.load();
CrechHomeController crechController = loader2.getController();
// get the paymentController to get the payment view
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/Views/Payment.fxml"));
Node node = loader.load();
PaymentController paymentController = loader.getController();
paymentController.reload();
paymentController.getRecherche().getSelectionModel().selectLast();
crechController.getBorderPane().setCenter(node);
}
}
I realize I may not be getting the correct Controller instance for the CrechHomeController
and taht's why I'm not getting anything, but how do you fix this if that's what is wrong, also I'm a Javafx newbie, so all help will be appreciated.