There’s nothing wrong with comments, but you need to use the right type. The lines are too long, which makes the code very difficult to read. Use /*...*/ comments over several lines, not one long //... comment. The same applies to those long array initialisers; they should be spread over several lines, otherwise they fall off the width of the screen.Al Dunne wrote: . . . sorry about all the comments . . .
Campbell Ritchie wrote:
What you are doing is going through a list of check boxes, and setting their selected-ness (grammar!) to match the value in the parallel boolean[] array.
Are you reading all those booleans from a file? I didn’t remember that. It is along time since I looked at that part of Head First Java™.When you start, I want you to select some of the check boxes. Select Nos 2 3 5 7 11 13 17 19 ... and un-select all the others.
Campbell Ritchie wrote:That code doesn’t change the state of the List at all. What it does, however, is get a reference to every Check Box in the List, and the next statement changes the state of that check box. My version did it all in one line.
No. There is no such thing as checkBoxState[i]. That is a List, and you are getting a reference to its i-th element, not [i] which is only used for arrays.Al Dunne wrote: . . . Am I right then in saying that "JCheckBox check = (JCheckBox) checkBoxState.get(i);" makes 'check' be a reference to checkBoxState[i] . . .
I'm a lumberjack and I'm okay, I sleep all night and work all day. Lumberjack ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|