Are there any good books or website that go over creating a JTable? I want to make one column editable. I would like to actually put a inherited JCheckBox
in your table Model, you should override "isCellEditable" and "setValueAt" functions, like below.
Column 4 is the column for editable cells.
Then when you double click the cell and type something,
setValueAt() will be called and save the value to the tableModel's DO,field col4.
public ArrayList tbmData = new ArrayList(); //arraylist for data in table
@Override
public boolean isCellEditable(int row, int col) {
if (col == 4) {
return true;
} else {
return false;
}
}
@Override
public void setValueAt(Object value, int row, int col) {
if ((row >= 0) && (row < this.tbmData.size()) && (col >= 0) && (col < this.colNm.length)) {
if (col == 4) {
tbmData.get(row).col4= (String) value;
}
fireTableCellUpdated(row, col);
} else {
}
}