Ok so I think the title is all I've got to ask here.
My AbstractTableModel
works fine, when I want to add an empty row, I use the following code to do so:
public void addRow() {
Object[][] oldData = data;
data = new Object[oldData.length + 1][3];
// Copy old data to new data
for (int x = 0; x < oldData.length; x++) {
data[x] = oldData[x];
}
// Append new row
data[oldData.length] = new Object[] {"", "", false};
fireTableRowsInserted(data.length - 2, data.length - 1);
}
Now, since I'm showing an empty row, I want the user to edit it, and I assume that the user will. Now, how do I make sure that the data is saved in my array as the user makes changes? Or, if that's not possible, what better alternative is there?
Ok so I should probably explain what I want to do:
I'm loading contents from a file, and displaying as a table. Now, the user might add new rows to the table on clicking the Add Row
button. This will add 1 empty row per click. (In this image above is an instance when the button is pressed twice.
Now, I want that the user can edit the cells, and then maybe delete some rows (maybe) but on clicking the Save Database
button, the updated data in the table is stores.