| Author |
How to detect row deselect in JTable
|
Avi Abrami
Ranch Hand
Joined: Oct 11, 2000
Posts: 1112
|
|
JDK 1.6.0_21 on Windows 2000
I want to know which row of a JTable was removed from the set of selected rows.
|
 |
Rob Camick
Ranch Hand
Joined: Jun 13, 2009
Posts: 1791
|
|
|
|
 |
Avi Abrami
Ranch Hand
Joined: Oct 11, 2000
Posts: 1112
|
|
Thanks Rob.
Now please pardon my ignorance, but how would I implement my ListSelectionListener interface in order to detect rows that were deselected.
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4167
|
|
Cache the selected indices in a int[] or List<Integer> and iterate over the list comparing with the new selection to find the changes
Alternatively, extend DefaultListSelectionModel and override methods that can deselect an item.
|
luck, db
There are no new questions, but there may be new answers.
|
 |
Avi Abrami
Ranch Hand
Joined: Oct 11, 2000
Posts: 1112
|
|
Thanks Darryl.
Your caching suggestion was how I thought to do it also but I thought perhaps there is some ready-made solution hiding in the Swing API somewhere that I was not aware of.
Cheers!
|
 |
 |
|
|
subject: How to detect row deselect in JTable
|
|
|