assuming DefaultTableModel? in a subclass of DefaultTableModel, add this:
Set nonEditableColumns = new HashSet();public void setColumnEditable(int col, boolean editable)
{
if (editable) nonEditableColumns.add(new Integer(col);
else nonEditableColumns.remove(new Integer(col)); // its ok if its not there
}public boolean isCellEditable(int row, int col)
{
return nonEditableColumns.contains(new Integer(col));
}
if its not already a subsclass, it will have to become one in order
to support the new method of setColumnEditable, or you can just internalize that
into the class that contains the model.
that is, the Set and setColumnEditable methods are in the class that
constructs the model, and the isCellEditable is part of an anonymous inner
class.
DefaultTableModel dtm = new DefaultTableModel()
{
public boolean isCellEditable(int row, int col)
{ ... }
};