
Originally Posted by
Dragon3002
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at test1.CheckBox.itemStateChanged(CheckBox.java:31)
I looked at line 31, but I can not find what is wrong.
Note: this is the line 31: if(whole_C_CheckBox.isSelected()){...etc

Originally Posted by
andbin
One thing is sure: the whole_C_CheckBox instance variable is not initialized.
Excuse me, but isn't this clear? You have a
whole_C_CheckBox that you use in itemStateChanged but that you don't inizialize.
You have (at least) 2 options:
1) Pass the JCheckBox reference to the CheckBox constructor and store it in whole_C_CheckBox instance variable.
2) Use the JCheckBox reference from the ItemEvent object (since the event comes from JCheckBox the e.getSource() clearly gives that JCheckBox!)