Skip to content
Advertisement

Java project can display a new scene pretty easily, but only for certain JavaFXML files, how to fix this?

Here’s my code I’m struggling with (I marked the line that’s giving me errors):

JavaScript

At this point, it does exactly what I want it to do, it loads a new scene of “CreateAccount.fxml” file whenever I click the login button. But I want it to load a different FXML file, so I change the name to “Dashboard.fxml” which is my dashboard file name, but all of a sudden it no longer works and it’s giving me errors that don’t make any sense since my path is right and my name is right as well. This is what I changed that line to to throw the error below:

JavaScript

Lastly, to make sure, I created a completely new and blank FXML file and it won’t load either.

Here are the full errors:

JavaScript

Here’s my Dashboard.fxml:

JavaScript

Here’s my CreateAccount.fxml:

JavaScript

So for some reason, my CreateAccount.fxml file loads, but not a completely new FXML file that’s blank or my Dashboard.fxml file. I’m not sure what the problem could be. Thanks in advance!

enter image description here

Advertisement

Answer

The problem is this line of the stack trace:

JavaScript

This means that the FXML loader could not find a class named Dashboard in package sample.view.

The FXML loader looked for this class because that is what was written in file Dashboard.fxml, namely:

JavaScript

Notice the part at the end of the line:

JavaScript

If you don’t need a controller class then simply remove that part.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement