ui/src/main/java/ucar/nc2/ui/table/ColumnWidthsResizer.java
@Override public void tableChanged(final TableModelEvent e) {
        if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
            return;  // Do not respond to changes in the number of columns here, only row and data changes.
        }

        // ColumnWidthsResizer requires that the internal Swing TableModelListeners that update the JTable view
        // run their updates BEFORE it does its thing. Unfortunately, the order in which listeners are notified is
        // undefined (see https://weblogs.java.net/blog/alexfromsun/archive/2011/06/15/swing-better-world-listeners).
        // As a work-around, we're going to place the resize operation at the end of the event queue. That way, it'll
        // be executed after all TableModelListeners have been notified.
        EventQueue.invokeLater(new Runnable() {
            @Override public void run() {
                // Do not cache the value of doFullScan; we need to reevaluate each time because the number of rows in
                // the table could have changed.
                boolean doFullScan = table.getRowCount() <= fullScanCutoff;

                if (e.getColumn() == TableModelEvent.ALL_COLUMNS) {
                    resize(table, doFullScan);  // Resize all columns.
                } else {
                    resize(table, e.getColumn(), doFullScan);  // Resize only the affected column.
                }
            }
        });
    }
@Override public void tableChanged(final TableModelEvent e) {
        if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
            return;  // Do not respond to changes in the number of columns here, only row and data changes.
        }

        // ColumnWidthsResizer requires that the internal Swing TableModelListeners that update the JTable view
        // run their updates BEFORE it does its thing. Unfortunately, the order in which listeners are notified is
        // undefined (see https://weblogs.java.net/blog/alexfromsun/archive/2011/06/15/swing-better-world-listeners).
        // As a work-around, we're going to place the resize operation at the end of the event queue. That way, it'll
        // be executed after all TableModelListeners have been notified.
        EventQueue.invokeLater(new Runnable() {
            @Override public void run() {
                // Do not cache the value of doFullScan; we need to reevaluate each time because the number of rows in
                // the table could have changed.
                boolean doFullScan = table.getRowCount() <= fullScanCutoff;

                if (e.getColumn() == TableModelEvent.ALL_COLUMNS) {
                    resize(table, doFullScan);  // Resize all columns.
                } else {
                    resize(table, e.getColumn(), doFullScan);  // Resize only the affected column.
                }
            }
        });
    }
@ Override public void tableChanged ( final TableModelEvent e ) { if ( e . getFirstRow ( ) == TableModelEvent . HEADER_ROW ) { return ; // Do not respond to changes in the number of columns here, only row and data changes. } // ColumnWidthsResizer requires that the internal Swing TableModelListeners that update the JTable view // run their updates BEFORE it does its thing. Unfortunately, the order in which listeners are notified is // undefined (see https://weblogs.java.net/blog/alexfromsun/archive/2011/06/15/swing-better-world-listeners). // As a work-around, we're going to place the resize operation at the end of the event queue. That way, it'll // be executed after all TableModelListeners have been notified. EventQueue . invokeLater ( new Runnable ( ) { @ Override public void run ( ) { // Do not cache the value of doFullScan; we need to reevaluate each time because the number of rows in // the table could have changed. boolean doFullScan = table . getRowCount ( ) <= fullScanCutoff ; if ( e . getColumn ( ) == TableModelEvent . ALL_COLUMNS ) { resize ( table , doFullScan ) ; // Resize all columns. } else { resize ( table , e . getColumn ( ) , doFullScan ) ; // Resize only the affected column. } } } ) ; }
////////////////////////////////////////////// TableModelListener ////////////////////////////////////////////////
////////////////////////////////////////////// TableModelListener ////////////////////////////////////////////////