You can now add MouseListener s, SelectionListener s, KeyListener and key bindings to try and solve this problem. Or you can go to the center of the problem.
ListSelectionModel is responsible for managing the details of the selection.
You can simply specify your own ListSelectionModel to select a row
public class ForcedListSelectionModel extends DefaultListSelectionModel { public ForcedListSelectionModel () { setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } @Override public void clearSelection() { } @Override public void removeSelectionInterval(int index0, int index1) { } }
And just set it to a table ...
table.setSelectionModel(new ForcedListSelectionModel());
Madprogrammer
source share