Ejemplo n.º 1
0
    /**
     * Overloaded the <code>mousePressed</code> event in the TrackListener.
     *
     * @see TrackListener#mousePressed(MouseEvent)
     */
    public void mousePressed(MouseEvent event) {
      // Check to see that the slider is enabled before proceeeding.
      if (!slider.isEnabled()) return;
      isDragging = true;
      // Get mouse x, y positions.
      currentMouseX = event.getX();
      currentMouseY = event.getY();

      // If the slider has {@link #setFocusEnabled} true then
      // request focus.
      if (slider.isRequestFocusEnabled()) slider.requestFocus();

      // Check to see if the thumb was clicked.
      if (thumbRect.contains(currentMouseX, currentMouseY)) super.mousePressed(event);

      if (showArrows) {
        if (minArrowRect.contains(currentMouseX, currentMouseY)) {
          int value = slider.getValue();
          isDragging = false;
          if (value > slider.getMinimum()) {
            // scrollTimer.stop();
            scrollListener.setScrollByBlock(false);
            scrollListener.setDirection(OneKnobSliderUI.NEGATIVE_SCROLL);
            // scrollTimer.start();
            slider.repaint();
          }
          return;
        }
        if (maxArrowRect.contains(currentMouseX, currentMouseY)) {
          int value = slider.getValue();
          isDragging = false;
          if (value < slider.getMaximum()) {
            // scrollTimer.stop();
            scrollListener.setScrollByBlock(false);
            scrollListener.setDirection(OneKnobSliderUI.POSITIVE_SCROLL);
            // scrollTimer.start();
            slider.repaint();
          }
          return;
        }
      }

      slider.repaint();
    }
Ejemplo n.º 2
0
 public void mousePressed(MouseEvent e) {
   super.mousePressed(e);
   Rectangle r = getTrackBounds();
   scrollbar.repaint(r.x, r.y, r.width, r.height);
 }