Writing a Class to Implement ListSelectionModel Directly?
I would like to implement my own ListSelectionModel without extending it from DefaultListSelectionModel, because I need some special list that behaves in a special way. How can I actually set the selection state of individual cells from setSelectionInterval , without using JList.setSelectionInterval (which itself calls ListSelectionModel.setSelectionInterval)? I can implement ListSelectionModel.isSelectedIndex correctly, but the problem I have is that it won't get called systematically...
What I need my list to do more specifically is to be able to change the selection state of any cell in the list if ListSelectionMode.setSelectionInterval gets called with a given range of indices. The only solution I have found so far is to extends DefaultListSelectionModel and then call:
in my overriden implementation of setSelectionInterval, after doing the necessary changes to my interval list such that my overriden implementation of isSelectedItnerval returns the right values. However, this solution is extremely inefficient and I want to avoid it if possible. As I said, I want to write my own class to implement ListSelectionModel instead of extending DefaultSelectionModel.