Trying to implement an MVC pattern, keep coming back to a NullPointerException.
I feel I’m missing a trick when it comes to setting up an area of the GUI which should
replot data based on user inputs. The exception points to this;
display.replot(model.getData(), model.getSamples());
display is an instance of a class which contains a paint method. getData and getSamples are described in the model and are based on setters which should update with user input to the GUI.
I thought the problem may have been with data set originally being null so i provided initial conditions to the model.
A
NullPointerExceptionmeans that either you are calling a function on a non-existing (null) object, or a function call can throw that exception deliberately if one of its parameters isnull. You need to check which is the case and either put anifguard around it or otherwise ensure the objects are valid.