This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Users are able to select an item from the catalogItems JList. I would like to be able to count the number of selections made. I was thinking I could use a SINGLE_INTERVAL_SELECTION mode and count the number of times the user hits the "Select" button and use that count to perform a calculation in the "Finish and Save" ActionEvent. But, I want to display each selection listed in custSelections - is it possible to append?
Alternatively, if I allow a MULTIPLE_INTERVAL_SELECTION, how do I count the number of items in the custSelections JList?
This may only be moderately helpful, bit IIRC, when allowing multiple selections, the selections are saved in an array/collection. Then they can be retrieved with either getSelectedIndices, or getSelectedValues. I did something similar with JFileChooser a long time ago, but the exact code escapes me at the moment.
That's about all I can recall of the process at the moment (and there is more to it). Maybe this will be enough to at least give you a push in the right direction.
Joined: Nov 20, 2005
Thanks, that gave me a start to search for a solution and I found it: