void (PropertyChangeEvent evt) { ListSelectionModel oldSelectionModel = null; ListSelectionModel newSelectionModel = null; if ("selectionModel".equals(evt.getPropertyName())) { oldSelectionModel = (ListSelectionModel)evt.getOldValue(); newSelectionModel = (ListSelectionModel)evt.getNewValue(); } else if ("columnModel".equals(evt.getPropertyName())) { TableColumnModel oldColumnModel = (TableColumnModel)evt.getOldValue(); oldSelectionModel = oldColumnModel != null ? oldColumnModel.getSelectionModel() : null; TableColumnModel newColumnModel = (TableColumnModel)evt.getNewValue(); newSelectionModel = newColumnModel != null ? newColumnModel.getSelectionModel() : null; } removeSelectionListener(oldSelectionModel); addSelectionListener(newSelectionModel); }