Reputation: 51
I have a JTable
, but I want to only select one column at a time.
I have seen ListSelectionModel.SINGLE_SELECTION
etc., but that is to only select one row at a time.
I want something similar to select one column, but multiple cells in the column.
Any ideas?
Upvotes: 1
Views: 2829
Reputation: 415
Use:
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
table.setColumnSelectionAllowed(true);
table.setRowSelectionAllowed(false);
This should be the correct answer.
Upvotes: 0
Reputation: 159864
Use:
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
table.setCellSelectionEnabled(true);
Upvotes: 4