Reputation: 41
I want to disable the possibility to select particular columns in a Jtable.
It's easy to disable the selection of certain rows with using the DefaultListSelectionModel
class
But I don't know how to do that for columns.
Can any one give me a clue to implement this feature ?
Upvotes: 4
Views: 152
Reputation: 7169
You can override the method isCellEditable
and implement as you want for example,
try this :
DefaultTableModel tableModel = new DefaultTableModel() {
@Override
public boolean isCellEditable(int row, int column) {
//Only the column nb 2
return column == 2;
}
};
table.setModel(tableModel);
Upvotes: 1