I'm using a JTable in java, but it won't let me edit the cells.
private final TableModel dataModel = new AbstractTableModel() {
public int getColumnCount() {
return 5;
}
public int getRowCount() {
return 10;
}
public Object getValueAt(int row, int col) {
return new Integer(row*col);
}
};
private final JTable table = new JTable(dataModel);
add the follwoing code
public boolean isCellEditable(int row, int col)
{ return true; }
public void setValueAt(Object value, int row, int col) {
rowData[row][col] = value;
fireTableCellUpdated(row, col);
}
you should have a array where you will save the changes
Add isCellEditable()
function inside the anonymous inner class AbstractTableModel
public boolean isCellEditable(int row, int col) {
return true;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With