Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+8 votes

I am getting the error Caused by: java.lang.IllegalStateException: Location is not set when trying to load a new FXML file after clicking a button to navigate to another page. How can I resolve this?"

asked in CSC 305 Fall 2024 by (3.6k points)

1 Answer

+2 votes

My guess is that this has something to do with when you are setting the root or calling the loader - you'll have to input the FXML class name exactly as a string with .fxml. For example:
FXMLLoader loader = new FXMLLoader(getClass().getResource("WelcomeScreen.fxml"));

answered by (4.4k points)
...