Class ColumnWidthPersistingJTable

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, RowSorterListener, TableColumnModelListener, TableModelListener, Scrollable

public class ColumnWidthPersistingJTable extends JTable
This is a JTable that remembers the size of its columns between runs of the program. The column sizes are stored in the provided Options object, under option names that begin with the provided prefix. We override the table's TableColumnModel with one that gets the desired width of the column from the Options when that column is being added to the table, and writes the new width back to the Options when columns are resided. This class doesn't actually persist the options. The caller is responsible for persisting the options before shutdown and reloading them before calling the constructor for this class. Note that the value we store not only includes the desired widths, but also the column order, but we aren't using the order information when creating the table so the columns always appear in their original order when the program is restarted. This could be enhanced in the future to restore column ordering.
Author:
Scott Greenman
See Also:
  • Constructor Details

    • ColumnWidthPersistingJTable

      public ColumnWidthPersistingJTable(String optionName, Options options, TableModel tableModel)