I am trying to insert multiple row in JTable using for loop. I m doing this on button click event. I want JTable to display/reflect each row immediately on UI after i insert it. but it is not reflecting until button click event complete.
I tryied repaint(),model.reflectdatachange(), validate(). and all other method but no luck. can someone please help here.
Note: All data is reflecting but after loop finish execution or we can say after button click action complete.
DefaultTableModel tableModel = new DefaultTableModel(null,new String[] {"Sr","Server", "Status"});
JTable jTable1=new JTable();
jTable1.setModel(tableModel_1);
//above code set from somewhere
//iterating over Arraylist withing button click
int table2_row_index=0;
for(String host:hostList){
//inserting table row
tableModel.insertRow(table2_row_index, new Object[] {table2_row_index+1,host,"some string"});
//Expected to reflect this row on UI immediately.so tried repaint((),revalidate(), fireTableDataChanged() and other but still row not reflecting until button-click event execute completely.
/* executing other code*/
//updating column
tableModel_2.setValueAt("updated string", table2_row_index, 2);
table2_row_index++;
}