The selection in one of my JLists is being highlighted with an outline rather than a solid background. The correct bounds rectangle for the selection is outlined, not filled with the background color. What makes this so perplexing to me is the fact that another JList in another window is highlighting its selections properly, and I am using the same code for both JLists (with the obvious change in parameter values). Here are the two chunks of code. First, the defective code:
Next, the properly working code:
As you can see, the two code fragments are identical save for the parameter entry values and the differences inside the ListSelectionListeners. I zeroed in on the defective code's call to method SetUpNextEncounters:
Here is that method:
More debugging established that the failure is caused by line 11 in the bottom chunk of code. Since it alters bigJList, I'm guessing that it generates a ListSelectionEvent, which then calls the valueChanged Listener, which calls SetUpNextEncounters -- and away we go. However, I trapped this out with the Boolean userInput and a breakpoint revealed that this is not the case. That I am NOT getting a recursive loop from this.
I searched the Java docs for material on ListSelectionEvents, but could not figure out how it's being messed up. At this point, I'm stumped. I'm guessing that I don't understand Event handling to understand the problem.
Thanks, Rob. The -1 parameter in setVisibleRowCount() is something I picked up in a demo that supposedly specifies some sort of default. Its one of those things that I got from somewhere that I have always used without a problem. I searched and found a number of sample programs that use it.
I have continued experimenting with the problem and come to the conclusion that modifying the JList in its own listener is just bad form. I had used a single method to handle a great many changes because it centralized everything and insured that all the interacting components were on the same page with the same data. I will break it down into specialized methods.
incandescent light gives off an efficient form of heat. You must be THIS smart to ride this ride. Tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java