Is there an easy(ish) way to add an additional row to an existing JTable's data?
I see that you can create a model of the table data using the
- TableModel dataModel = theTable.getModel();
But TableModel has no 'insertRow()' method.
I also see that DefaultTableModel has the insertRow() method, but I can not see a way to use DefaultTableModel with an existing table (seems to be specific for a new table). I tried casting but you can not cast TableModel as (DefaultTableModel).
Is there a simple way of doing this(something like):
You can always create your JTable using a DefaultTableModel right from the start, and then use that model to add rows. It's simple and easy to do.
Best of luck!
Kevin P Smith
Joined: Feb 18, 2005
I've got as far as:
But at the point of [defaultModel.addRow(rowData);] whilst debugging the 'rowData' shows it has the expected values from the existing row, when I debug the 'defaultModel' the elementData shows 'nulls'.