My MVC design for my GUI has a TableModel that is updated with the correct number of rows to display depending on the Search/Search All results.
My problem is that I have a TableColumnModel instance variable as part of the main gui. In the constructor of my main gui, I set my TableColumnModel variable in the following fashion:
Now, using setAutoCreateColumnsFromModel() seems to be the only way to prevent my mainTable from losing it's columnModel settings since they are recreated every time I re-render the table using mainTable.setModel().
It works, but is there a better way, such as tying my column formatting in my TableModel? I could also create a new class MyTableColumnModel and call mainTable.setColumnModel() after every setModel() call, but that seems like overkill since I am not formatting my columns that much. I could also alter my method that performs the mainTable.setModel() call to format the columns every time, but again, seems like more work than needed.