I have problem with changing scenes in my application which looks like
Main screen > Login screen
I am storing screens in main file as <
The exception is pretty self-explanatory: the anchor pane cannot be the root of two different scenes. Instead of creating a new scene every time, just replace the root of the existing scene:
@FXML
private void LogIn(ActionEvent event) {
Button button = (Button) event.getSource();
Scene scene = button.getScene();
Parent root = MyApplication.pages.get("LoginPage");
scene.setRoot(root);
}