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());
        }
      }
    }
  }
示例#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()));
    }
  }
示例#3
0
 private void moveScrollBar(int k) {
   myBoundedRangeModel.setValue(myBoundedRangeModel.getValue() + k);
 }
示例#4
0
 private void scrollToBottom() {
   myBoundedRangeModel.setValue(myTermSize.height);
 }