예제 #1
0
  /**
   * Checks for an auto scroll event. This should be called when a drag & drop operation is in
   * progress and the drop target is inside a scroll pane.
   *
   * @param evt the mouse event which should be checked.
   * @return true if auto scrolling is started/active.
   * @see #stopAutoScroll()
   */
  public boolean checkAutoScroll(Event evt) {
    GUI gui = getGUI();
    if (gui == null) {
      stopAutoScroll();
      return false;
    }

    autoScrollDirection = getAutoScrollDirection(evt);
    if (autoScrollDirection == 0) {
      stopAutoScroll();
      return false;
    }

    setAutoScrollMarker();

    if (autoScrollTimer == null) {
      autoScrollTimer = gui.createTimer();
      autoScrollTimer.setContinuous(true);
      autoScrollTimer.setDelay(AUTO_SCROLL_DELAY);
      autoScrollTimer.setCallback(
          new Runnable() {
            public void run() {
              doAutoScroll();
            }
          });
      doAutoScroll();
    }
    autoScrollTimer.start();
    return true;
  }