I have multiple Jlist components. When an item in the first list is selected, the next list should dynamically display a new set of possible selections.
For example, the first list might have three items which are "A" ,"B" ,"C". When I click "A", the next list should show 1, 2, 3, 4, 5, etc. When I click "B" the next list should show 7, 8, 9, etc. I need these lists to work on this logic.
The aim is to implement a GUI like this:


In outline,
Add a
ListSelectionListenerto the firstJList.In the selection handler, use
setModel()to set the second list's model to the correctListModelfor the current selection.Similarly, add a
ListSelectionListenerto the secondJListand update the third panel accordingly.A similar approach is shown here for
ComboBoxModel. This related example uses a similar approach to display a file system tree in columns.