Hi. I found a lot of answered questions about this topic but nothing seems to work for me and I just cant get my head around it. The idea is to clear a StackPane (changablePane in my code) so that another item can be displayed depending on the selected item in the filter combo boxes.
I commend you for working with JavaFX- it's pretty nifty, and offers a lot of advantageous over AWT/swing. I do have to say though mate, you posted a lot of code. JavaFX with the FXML allows for dynamic run-time loading, so you don't have to use as much code-behind. This is convenient, but there's several places where a variable could be uninitialized. Have you tried running this in debug? Where does the program get to right before it gets a NullPointer? A little more detail of the line the exception is occurring on, or the calling function would be very helpful here.
Hi Grant. I should have mentioned where i get the nullPointerException and post the code that i used to try and get an instance of the MainWindowController, sorry for that. Wtih the code above i got a nullPointer in the call of mainController.clearPane. I tried a different approach:
and now i get a null pointer exception in the clearPane method in mainWindowController.
Here is the whole stacktrace of the nullPointer
My plan is to use the same code for a bunch of other things in my app. If you think that i should try a different way and somehow restructure my app please let me know, i would really appreciate any suggestion.
When the user opens the window the sort box is empty, and then he selects something which should run the code from the mainWindowController. I know that the problem is with the way I'm getting the instance of the controller so I made some changes and now the changablePane is not created by the fxml file, I'm creating it by java code and made it static. That way I can make the clearPane() mehod static and call it from another class without creating an instance of the MainWindowCotroller. Now the problem is that the app doesnt show the changablePane with the filtered notes after it clears it.
Filip Kekev wrote:When the user opens the window the sort box is empty, and then he selects something which should run the code from the mainWindowController. I know that the problem is with the way I'm getting the instance of the controller so I made some changes and now the changablePane is not created by the fxml file, I'm creating it by java code and made it static. That way I can make the clearPane() mehod static and call it from another class without creating an instance of the MainWindowCotroller. Now the problem is that the app doesnt show the changablePane with the filtered notes after it clears it.
Can you post your code?
All things are lawful, but not all things are profitable.