Example #1
0
  /**
   * Sets the model's {@code valueIsAdjusting} property. Slider look and feel implementations should
   * set this property to {@code true} when a knob drag begins, and to {@code false} when the drag
   * ends.
   *
   * @param b the new value for the {@code valueIsAdjusting} property
   * @see #getValueIsAdjusting
   * @see BoundedRangeModel#setValueIsAdjusting
   * @beaninfo expert: true description: True if the slider knob is being dragged.
   */
  public void setValueIsAdjusting(boolean b) {
    BoundedRangeModel m = getModel();
    boolean oldValue = m.getValueIsAdjusting();
    m.setValueIsAdjusting(b);

    if ((oldValue != b) && (accessibleContext != null)) {
      accessibleContext.firePropertyChange(
          AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
          ((oldValue) ? AccessibleState.BUSY : null),
          ((b) ? AccessibleState.BUSY : null));
    }
  }
Example #2
0
  /**
   * Sets the slider's current value to {@code n}. This method forwards the new value to the model.
   *
   * <p>The data model (an instance of {@code BoundedRangeModel}) handles any mathematical issues
   * arising from assigning faulty values. See the {@code BoundedRangeModel} documentation for
   * details.
   *
   * <p>If the new value is different from the previous value, all change listeners are notified.
   *
   * @param n the new value
   * @see #getValue
   * @see #addChangeListener
   * @see BoundedRangeModel#setValue
   * @beaninfo preferred: true description: The sliders current value.
   */
  public void setValue(int n) {
    BoundedRangeModel m = getModel();
    int oldValue = m.getValue();
    if (oldValue == n) {
      return;
    }
    m.setValue(n);

    if (accessibleContext != null) {
      accessibleContext.firePropertyChange(
          AccessibleContext.ACCESSIBLE_VALUE_PROPERTY,
          Integer.valueOf(oldValue),
          Integer.valueOf(m.getValue()));
    }
  }
 public synchronized void setPlayer(Player player) {
   if (this.player != null) {
     this.player.removeChangeListener(this);
     player.removePropertyChangeListener(this);
   }
   this.player = player;
   //        boundedRangeModel = player == null ? null : player.getBoundedRangeModel();
   boundedRangeModel = player == null ? null : player.getTimeModel();
   slider.setModel(boundedRangeModel);
   if (player != null) {
     if (player.getState() >= Player.REALIZED
         && boundedRangeModel != null
         && boundedRangeModel.getMaximum() == 0) {
       setPlayerControlsVisible(false);
     }
     slider.setProgressModel(player.getCachingModel());
     startButton.setSelected(player.isActive());
     player.addChangeListener(this);
     player.addPropertyChangeListener(this);
     audioButton.setVisible(player.isAudioAvailable());
     audioButton.setSelected(player.isAudioEnabled());
     colorCyclingButton.setVisible(
         (player instanceof ColorCyclePlayer)
             ? ((ColorCyclePlayer) player).isColorCyclingAvailable()
             : false);
     colorCyclingButton.setSelected(
         (player instanceof ColorCyclePlayer)
             ? ((ColorCyclePlayer) player).isColorCyclingStarted()
             : false);
     validate();
     repaint();
     BoundedRangeModel cachingControlModel = slider.getProgressModel();
   }
 }
  public void actionPerformed(ActionEvent event) {
    Object source = event.getSource();
    if (boundedRangeModel != null) {
      int value = boundedRangeModel.getValue();
      if (source == forwardButton) {
        boundedRangeModel.setValue(
            value == boundedRangeModel.getMaximum() ? boundedRangeModel.getMinimum() : value + 1);
      } else if (source == rewindButton) {
        boundedRangeModel.setValue(
            value == boundedRangeModel.getMinimum() ? boundedRangeModel.getMaximum() : value - 1);
      } else if (source == startButton) {
        if (startButton.isSelected() != player.isActive()) {
          if (startButton.isSelected()) {
            player.start();
          } else {
            player.stop();
          }
        }
      } else if (source == audioButton) {

        player.setAudioEnabled(audioButton.isSelected());
      } else if (source == colorCyclingButton) {
        if (player instanceof ColorCyclePlayer) {
          ((ColorCyclePlayer) player).setColorCyclingStarted(colorCyclingButton.isSelected());
        }
      }
    }
  }
Example #5
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);
  }
Example #6
0
 /**
  * Get the maximum accessible value of this object.
  *
  * @return The maximum value of this object.
  */
 public Number getMaximumAccessibleValue() {
   // TIGER - 4422362
   BoundedRangeModel model = JSlider.this.getModel();
   return Integer.valueOf(model.getMaximum() - model.getExtent());
 }