Пример #1
0
  /**
   * Sets the model that handles the scrollbar's four fundamental properties: minimum, maximum,
   * value, extent.
   *
   * @see #getModel
   * @beaninfo bound: true expert: true description: The scrollbar's BoundedRangeModel.
   */
  public void setModel(BoundedRangeModel newModel) {
    Integer oldValue = null;
    BoundedRangeModel oldModel = model;
    if (model != null) {
      model.removeChangeListener(fwdAdjustmentEvents);
      oldValue = Integer.valueOf(model.getValue());
    }
    model = newModel;
    if (model != null) {
      model.addChangeListener(fwdAdjustmentEvents);
    }

    firePropertyChange("model", oldModel, model);

    if (accessibleContext != null) {
      accessibleContext.firePropertyChange(
          AccessibleContext.ACCESSIBLE_VALUE_PROPERTY, oldValue, new Integer(model.getValue()));
    }
  }
Пример #2
0
  /**
   * Sets the {@code BoundedRangeModel} that handles the slider's three fundamental properties:
   * minimum, maximum, value.
   *
   * <p>Attempts to pass a {@code null} model to this method result in undefined behavior, and, most
   * likely, exceptions.
   *
   * @param newModel the new, {@code non-null} <code>BoundedRangeModel</code> to use
   * @see #getModel
   * @see BoundedRangeModel
   * @beaninfo bound: true description: The sliders BoundedRangeModel.
   */
  public void setModel(BoundedRangeModel newModel) {
    BoundedRangeModel oldModel = getModel();

    if (oldModel != null) {
      oldModel.removeChangeListener(changeListener);
    }

    sliderModel = newModel;

    if (newModel != null) {
      newModel.addChangeListener(changeListener);
    }

    if (accessibleContext != null) {
      accessibleContext.firePropertyChange(
          AccessibleContext.ACCESSIBLE_VALUE_PROPERTY,
          (oldModel == null ? null : Integer.valueOf(oldModel.getValue())),
          (newModel == null ? null : Integer.valueOf(newModel.getValue())));
    }

    firePropertyChange("model", oldModel, sliderModel);
  }