im using Jtable and i filtered rows but i cant add aditional rows dynamically pls any one help me..Thank you.
A:
You want to use/access the underlying TableModel, this way you can update the data and can notify the table when the data has changed.
Object[][] data = new Object[][] { };
this.tableModel = new DefaultTableModel(data, new String[] { "",
"Title", "Rating" });
JTable table = new JTable(this.tableModel);
To simple add a row:
this.tableModel.addRow(Object[] rowData);
Or you can change the entire table model data:
this.tableModel.setDataVector(data, new String[] { "",
"Title", "Rating" });
And fire the event to let the table know:
this.tableModel.fireTableRowsInserted(firstRow, lastRow);
or
this.tableModel.fireTableDataChanged();
dekz
2010-10-23 10:32:34
but im unable to add in the middle of the rows pls help me to in the middle of the rows for the filtered table.
2010-10-23 11:58:56
Check out the insertRow of the TableModel javadoc linked above.
dekz
2010-10-25 11:38:12