love fox wrote:
but still i got a NULL POINTER EXCEPTION after i compiled.. guys please help
The NPE will tell you exactly which line is causing it. On that line you are trying to use an object that has not been initialized. For instance, I see that you've declared a JCheckBox array but I don't see that you've ever initialized it. Perhaps this is causing your problem.
Other suggestions:
1) Use descriptive variable names throughout. For example, instead of p2, use chkBoxPanel, instead of e, use checkBoxListener, etc...
2) use an array of
String for your checkbox labels. This way you can consolidate your code quite a bit. i.e.,
3) Put in clinic a public method to count the number of checkboxes clicked (easy if you have traverse the array). Have the Listener call this method.
4) Put in clinic a public method to change the charge label