I want to store the results of reading lucene index into jTable, so that I can make it sortable by different columns. From index I am reading terms with different measures o
There is no need to create a custom TableModel for this. Just use the DefaultListModel.
The DefaultListModel allows you to dynamcially add rows to the model using the addRow(...) method and it automatically invokes the appropriate fireXXX method to tell the table to repaint itself.
The basic code would be:
DefaultTableModel model = new DefaultTableModel( columnNames );
while (...)
{
Vector row = new Vector();
row.add(...)
row.add(...)
model.addRow( row );
}
JTable table = new JTable( model );
You don't need to create a custom TableModel everytime. Sometimes you can start with the DefaultTableModel.