I'm having a hard time to put action listeners on multiple check boxes, that are on a panel and bordered. Like for example : if a checkbox is selected,than it must update an int, in my case that is total, and if more than one is selected the total must be updated. This is what I'm doing :
public void actionPerformed(ActionEvent a) {
if (hat.isSelected()) {
total += 50;
}
}
But I'm getting an error, One more question, how do I make it so that I can put multiple item listeners in a class. P.s : I'm a beginner at coding GUI-s in Java. Help would be very appreciated.
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Projekt.actionPerformed(Projekt.java:61)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
Edit : Added Error Codes