저는 javafx를 처음 접했습니다. 나는 화면을 전환하는 많은 방법을 보았다. 그러나 그들은 어떻게 든 생각을 해본 후에 어떻게 든 작동하지 않았다. 나는이 논리를 사용하는 것을 생각했다. 제가 프로젝트에서 너무 멀리 가기 전에 제가 계속해서 조언을 해줄 수 있는지 알아야합니다.Javafx fxml 화면 전환하기
@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);
}
버튼 중 하나를 클릭하면 현재 장면이 제거되고 관련 fxml이로드됩니다. 감사합니다. passangerPaymentAnchorPane은 다른 fxml이로드 및 언로드되는 마더 패널과 같은 역할을합니다.
고맙습니다. –