Good evening
I have a JTable that I built with a TableModel how to update the elements of the table, because when I do table = new JTable (new TableProg (elementTab)) I create another table above the original table and it is very ugly
So for example how to update element of table in a loop at each iteration as “elementTab” changes?
thank you very much
I recommend you to extend an AbstractTableModel and implement an
void addRow(YourObject row)that fits you. Or if you want to update the hole tables data, you could implement anvoid addElements(YourCollection elements)and use thevoid fireTableDataChanged()-method.I.e. keep your data in a
LinkedListand don’t forget to usevoid fireTableRowsInserted(int firstRow, int lastRow)when you add a new row.