Switching Javafx fxml screens


Question

i am quite new to javafx. I saw many ways of switching between screens but they somehow didn't work after some thinking, i thought of using this logic. Please i need to know if it is advice-able for me to continue with it, before i go too far in the project.

 @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);
}

when i click on one of the buttons, it removes the current scene and loads the related fxml. Thank You. The passangerPaymentAnchorPane acts like the mother pane on which other fxml loads and unload

1
0
7/16/2013 7:20:25 PM

I have also struggled with javaFx multiscreen issue. Finally I solved as follows. I am added the code in github

https://github.com/nrkkalyan/javafx

Feel free to comment or any suggestions.

1
1/23/2014 12:21:59 AM

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