I have an input panel and want to call a method in another class when the button is pressed but am getting a null pointer exception. Was hoping someone might be able to tell me what I’m doing wrong?
Here is the code causing it:
public void actionPerformed(ActionEvent ae)
{
if (ae.getSource() == resultsButton)
{
jbTour.processAdditionalResult();
}
}
public void processAdditionalResult()
{
System.out.println("button pressed");
}
You need to initialize jbTour:
jbTour = new JBTourObject()(or whatever) so that it is not null before theactionPerformedmethod gets invoked.