How does this reply answer my question?
isCellEditable will tell me whether or not a cell is editable. I don't care if it is. I want to make the entire table not editable.
If I don't enable the table then the user will not be able to select a row. I want the user to be able to select a row but not be able to any cells in the table.
redifine the model of your table in this way. However, reading the API you may understand many things.
DefaultTableModel model = new DefaultTableModel(contenuto, header) {
public boolean isCellEditable (int row, int col) {
return false;
}
};
table.setModel(model);
}
Ok, so if I want to make the table editable for some users I would have to check who the user is first and return either true or false from isCellEditable? Is this the best way to do it? It seems to add a layer of complication in my table model (which is a custom table model).
Thank you though for your more comprehensive reply.
> Ok, so if I want to make the table editable for some
> users I would have to check who the user is first and
> return either true or false from isCellEditable? Is
> this the best way to do it? It seems to add a layer
> of complication in my table model (which is a custom
> table model).
> Thank you though for your more comprehensive reply.
yes, you should do in the way you explained!
> It seems to add a layer of complication in my table model...
I always override the isCellEditable(...) method of JTable. I believe the TableModel should be for storing data.
The table is used for the view of the data. I believe being editable or not is a function of the view not on how the data is stored.