@ Override public void setModel ( TableModel newModel ) { if ( ! ( newModel instanceof PropertySheetTableModel ) ) { throw new IllegalArgumentException ( "dataModel must be of type " + PropertySheetTableModel . class . getName ( ) ) ; } if ( cancelEditing == null ) { cancelEditing = new CancelEditing ( ) ; } TableModel oldModel = getModel ( ) ; if ( oldModel != null ) { oldModel . removeTableModelListener ( cancelEditing ) ; } super . setModel ( newModel ) ; newModel . addTableModelListener ( cancelEditing ) ; // ensure the "value" column can not be resized getColumnModel ( ) . getColumn ( 1 ) . setResizable ( false ) ; }
Overriden to register a listener on the model . This listener ensures editing is canceled when editing row is being changed .