tags:

views:

44

answers:

1

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
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.
Check out the insertRow of the TableModel javadoc linked above.
dekz