Reputation:
I was wondering what the best way is to make it so that only one row at a time can be selected in a JTable? Is there a method to set this which I have missed or do I need to override it is some way?
I am using Oracle JDK 8.
Upvotes: 1
Views: 536
Reputation: 18792
You need to:
table.setRowSelectionAllowed(true);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
Upvotes: 1