My program is supposed to run my SignIn.fxml on initial run, with the controller named LoginController. However when I run the usual code:
public void showLoginScreen() {
try {
FXMLLoader loader = new FXMLLoader(
getClass().getResource("SignIn.fxml"));
Parent root = (Parent) loader.load(getClass().getResource("SignIn.fxml"));
scene = new Scene(root);
LoginController.initManager(this);
}catch (IOException ex) {
Logger.getLogger(LoginManager.class.getName()).log(Level.SEVERE, null, ex);
}
}
I get an exception stating
javafx.scene.Scene cannot be cast to javafx.scene.Parent
I cannot understand this, as it has worked for me in past projects.
I have the scene set as a variable in the controller class.
I have checked my FXML file and found the cause of my problem is a conflict in my fxml file having a scene and the dynamically created scene on my controller itself.