JTable simply checks getEditable()
You would have to put the behavior in your TableModel and do:
(ReadWriteModel) table.getModel()).setEditable(row, col, false);
Some approaches are:
* if you have a custom TableModel implement it there
* subclass DefaultTableModel to track a Map of Point objects:
private final Map _editState = new HashMap(); // Map<Point, Boolean>
public void setEditable(int row, int col, boolean value) {
_editState.put(new Point(row, col), value ? Boolean.TRUE : Boolean.FALSE;
}
// override getEditable
public void getEditable(int row, int col) {
Boolean editable = (Boolean) _editState.get(new Point(row, col));
return (editable != null) ? editable.booleanValue : false; // assumes false by default
}
* Implement the above code snippets as a TableModelDecorator.
See Geary's article: http://www.javaworld.com/javaworld/jw-12-2001/jw-1214-designpatterns.html
You can then "plug" in that behavior without affecting the underlying model.
~rmp
Ralph M. Prescott
Technical Lead / Solutions Development
Xelus, Inc.
web: http://www.xelus.com
email: [EMAIL PROTECTED]
vmail: 585.419.3137
im: rmprescott@yahoo
-----Original Message-----
From: Bruce Jin [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 24, 2003 12:36 PM
To: [EMAIL PROTECTED]
Subject: Enable/disable 'table cell editable' dynamically.
Can I do this? I don't see a method like JTable.setEditable(row, col);
