/**
   * Sets the selection model for this <code>TableColumnModel</code> to <code>newModel</code> and
   * registers for listener notifications from the new selection model. If <code>newModel</code> is
   * <code>null</code>, an exception is thrown.
   *
   * @param newModel the new selection model
   * @exception IllegalArgumentException if <code>newModel</code> is <code>null</code>
   * @see #getSelectionModel
   */
  public void setSelectionModel(ListSelectionModel newModel) {
    if (newModel == null) {
      throw new IllegalArgumentException("Cannot set a null SelectionModel");
    }

    ListSelectionModel oldModel = selectionModel;

    if (newModel != oldModel) {
      if (oldModel != null) {
        oldModel.removeListSelectionListener(this);
      }

      selectionModel = newModel;
      newModel.addListSelectionListener(this);
    }
  }
Example #2
0
 public void cleanUp() {
   if (lsm != null) {
     lsm.removeListSelectionListener(selListener);
   }
 }