Is there any way to make non editable cell dynamically in jtable ? Whenever user gives input like false, i want to make non editable cell...I have seen in DefaultTableModel
I had similar problems to figure out how to enable/disable editing of a cell dynamically (in my case based on occurences in a database.) I did it like this:
jTableAssignments = new javax.swing.JTable() {
public boolean isCellEditable(int rowIndex, int colIndex) {
return editable;
}};
That of course overrides isCellEditable. The only way I could make that work by the way, was to add the declaration to the instantiation of the tabel itself and not the table model.
Then I declared editable as a private boolean that can be set e.g.:
private void jTableAssignmentsMouseClicked(java.awt.event.MouseEvent evt) {
if(jTableAssignments.getSelectedRow() == 3 & jTableAssignments.getSelectedColumn() == 3) {
editable = true;
}
else {
editable = false;
}
}
And it works quite well.