Example #1
0
    /*
     * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
     */
    public void propertyChange(PropertyChangeEvent evt) {

      TableModel old = (TableModel) evt.getOldValue();
      TableModel knew = (TableModel) evt.getNewValue();

      if (old != null) old.removeTableModelListener(autoTailTracker_);

      if (knew != null) knew.addTableModelListener(autoTailTracker_);
    }
  //
  //  Implement the PropertyChangeListener
  //
  public void propertyChange(PropertyChangeEvent e) {
    //  When the TableModel changes we need to update the listeners
    //  and column widths

    if ("model".equals(e.getPropertyName())) {
      TableModel model = (TableModel) e.getOldValue();
      model.removeTableModelListener(this);

      model = (TableModel) e.getNewValue();
      model.addTableModelListener(this);
      adjustColumns();
    }
  }
  /**
   * Overriden to register a listener on the model. This listener ensures editing is cancelled when
   * editing row is being changed.
   *
   * @throws IllegalArgumentException if dataModel is not a {@link PropertySheetTableModel}
   * @see javax.swing.JTable#setModel(javax.swing.table.TableModel)
   */
  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);
  }
 public void removeTableModelListener(TableModelListener l) {
   original.removeTableModelListener(l);
 }
 public void removeTableModelListener(final TableModelListener l) {
   model.removeTableModelListener(l);
 }