私はjavafxにかなり慣れていません。画面を切り替える方法はたくさんありましたが、どうにかうまくいかず、このロジックを使用することを考えました。プロジェクトをやりすぎる前に、それを続けることができるかどうかを知る必要があります.
@FXML
public void nextAfterPassangerButtonClicked() throws Exception {
MainScreenDatabaseHandler a = new MainScreenDatabaseHandler(getId(), getFirstName(), getLastName(), getOtherName(), getSexSelection(), getMobileNumber(), getEmergencyContact(), getHomeAdress());
//send collected data to database
passangerPaymentAnchorPane.getChildren().remove(0);
Node node = FXMLLoader.load(getClass().getResource("CargoPayment.fxml"));
passangerPaymentAnchorPane.getChildren().add(node);
}
//Handle All Menu Bar Buttons
@FXML
public void startPageBarButtonClicked() throws Exception {
passangerPaymentAnchorPane.getChildren().remove(0);
mainAnchor.getChildren().remove(0);
Node node = FXMLLoader.load(getClass().getResource("MainScreen.fxml"));
mainAnchor.getChildren().add(node);
}
public void allPassangersMenuBarButtonClicked() throws Exception {
passangerPaymentAnchorPane.getChildren().remove(0);
Node node = FXMLLoader.load(getClass().getResource("AllPassangersView.fxml"));
passangerPaymentAnchorPane.getChildren().add(node);
}
ボタンの 1 つをクリックすると、現在のシーンが削除され、関連する fxml が読み込まれます。ありがとうございました。passangerPaymentAnchorPane は、他の fxml がロードおよびアンロードされるマザー ペインのように機能します。