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] . . .
Those who dance are thought mad by those who hear not the music. This tiny ad plays the bagpipes:
how do I do my own kindle-like thing - without amazonhttps://coderanch.com/t/711421/engineering/kindle-amazon