I also ran into this problem. All published solutions did not work for me, because if I call DefaultListModel # remove (int), it will change the base list and therefore the indexes that I collected earlier with JList # getSelectedIndices () are no longer valid.
I came to this solution that worked for me.
for (MyObject o : jList1.getSelectedValuesList()) { ((DefaultListModel<MyObject>)jList1.getModel()).removeElement(o); }
When processing selected objects, I donโt need to worry about indexes and their validity.
Chris source share