try to get resizing to be remembered and restored. (#2269)

Per tsinmw: Simplify to use mTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS)
This commit is contained in:
Alan Crosswell
2025-11-22 05:24:30 -05:00
committed by GitHub
parent f6866f5408
commit bbde3033b7
2 changed files with 7 additions and 2 deletions

View File

@@ -96,7 +96,6 @@ public class DecodeEventPanel extends JPanel implements Listener<ProcessingChain
mTableRowSorter = new TableRowSorter<>(mEventModel);
mTableRowSorter.setRowFilter(new EventRowFilter());
mTable.setRowSorter(mTableRowSorter);
mTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
mTableColumnWidthMonitor = new JTableColumnWidthMonitor(mUserPreferences, mTable, TABLE_PREFERENCE_KEY);
updateCellRenderers();
mHistoryManagementPanel = new HistoryManagementPanel<>(mEventModel, "Event Filter Editor");

View File

@@ -25,6 +25,7 @@ import io.github.dsheirer.util.ThreadPool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.EventQueue;
import javax.swing.JTable;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ListSelectionEvent;
@@ -60,7 +61,12 @@ public class JTableColumnWidthMonitor
mTable = table;
mKey = key;
restoreColumnWidths();
mTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
// Wait until the UI is realized to set preferred column widths
EventQueue.invokeLater(this::restoreColumnWidths);
// Keep listening for drag-resizes so you can re-save new widths
mTable.getColumnModel().addColumnModelListener(mColumnResizeListener);
}