views:

521

answers:

2

Hi, Im doin a project using JTable, i want to make my table cells editable. I used, public boolean isCellEditable(int row, int column) {
return true;
} My problem is, the cells are ediable but once after entering data into one cell and move on to the next, the previous data gets erased... kindly any one help me...

+1  A: 

Override setValueAt(Object value, int row, int col) method as well. It should store entered data, so getValueAt(int row, int col) method can return new value. Something like this:

private String[][] data;
public Object getValueAt(int row, int col) {
    return data[row][col];
}
public void setValueAt(Object value, int row, int col) {
    data[row][col] = value;
}
A: 
public void setValueAt(Object value, int row, int col) {
 datum[row][col]=value;
 fireTableCellUpdated(row, col);
}