'Get multiple selected items from a JList
I am creating a screen with four lists on it. Basically two pairs of lists where you can select lines on one list in the pair and move them to the other list in the pair.
Looking at the documentation I need a ListSelectionModel for each list to determine which lines have been selected. I will use a [Sel] or [Des] button to do the actual transfer.

The documentations and samples say I need a ListSelectionListener but as I will not access the model until the user clicks on the button do I actually need a listener? Will the model still have the getMinSelectionIndex, getMaxSelectionIndex and isSelectedIndex set if I do not have a listener?
Solution 1:[1]
but as I will not access the model until the user clicks on the button do I actually need a listener?
No. The listener is just needed for notification of the list's items being selected or deselcted, and since you're waiting for notification from the JButton, its ActionListener is all that you need.
Will the model still have the getMinSelectionIndex, getMaxSelectionIndex and isSelectedIndex set if I do not have a listener?
This has nothing to do with the listener. The model should still give you this information if you request it.
But why ask these questions? This is easily discoverable by simple testing.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Hovercraft Full Of Eels |
