0

For my JTable I am using a DefaultListSelectionModel. There is a setSelectionInteral(int index0, int index1) and addSelectionInteral(int index0, int index1). These work great if I have one contiguous selection or a single selection. What if I have lots of individual or noncontinuous selections? Adding a thousand single selections is very slow. Should I be using another class to drive my JTable selections? I do not understand why I cannot supply a List of selected indexes all at once, why only intervals?

smuggledPancakes
  • 9,881
  • 20
  • 74
  • 113
  • Can you amplify on the purpose of such a complex selection? An [sscce](http://sscce.org/) may be helpful. – trashgod Mar 07 '13 at 23:06

1 Answers1

3

Instead of trying to maintain a complex state in your ListSelectionModel, consider storing the state in the TableModel and letting a renderer signify the state, for example.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • 1
    I agree (like it would matter if I didn't ;)), using selection to "highlight" cells probably isn't a good idea +1 – MadProgrammer Mar 07 '13 at 23:33
  • @MadProgrammer: I welcome your insights! A custom `ListSelectionModel` _might_ be warranted, but updating a `TableModel` is easier to optimize. – trashgod Mar 08 '13 at 00:12