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

+12 votes

I have a method in the app class that returns the main window (stage), and when I call the method from the controller class inside the initialize function, it returns null. How to fix that?

asked in CSC305 Fall 2022 by (1 point)

2 Answers

+6 votes

I think it's because the scene is not initialized, you need to have it initialized in order to access the stage.

answered by (1 point)
+3 votes

Initialize is what happens when you originally open the scene. Behind the scenes it makes a lot of fxml data that you can get such as stage.

answered by (1 point)
...