public void onMouseDown(Widget sender, int x, int y) {
   float newPercent = (float) x / (float) base.getOffsetWidth();
   int newPosition =
       Math.round(
               (target.getOffsetWidth() + target.getMaxHorizontalScrollPosition())
                   * newPercent)
           - (target.getOffsetWidth() / 2);
   Logger.getAnonymousLogger().log(Level.SPAM, "New Position: " + newPosition, null);
   target.setHorizontalScrollPosition(newPosition);
 }
        public void onMouseDown(Widget sender, int x, int y) {
          float newPercent =
              (float) (x + lower.getOffsetWidth() + bar.getOffsetWidth())
                  / (float) base.getOffsetWidth();
          int newPosition =
              Math.round(
                      (target.getOffsetWidth() + target.getMaxHorizontalScrollPosition())
                          * newPercent)
                  - (target.getOffsetWidth() / 2);

          target.setHorizontalScrollPosition(newPosition);
        }
        public void onMouseMove(Widget sender, int x, int y) {
          if (inDrag) {
            float newPercent =
                (float) ((x - start) + lower.getOffsetWidth()) / (float) base.getOffsetWidth();
            Logger.getAnonymousLogger().log(Level.SPAM, x + " " + newPercent, null);

            int newPosition =
                Math.round(
                        (target.getOffsetWidth() + target.getMaxHorizontalScrollPosition())
                            * newPercent)
                    + x;
            target.setHorizontalScrollPosition(newPosition);
          }
        }
 protected void onDetach() {
   super.onDetach();
   Window.removeWindowResizeListener(this.windowListener);
   this.lowerTarget.removeMouseListener(this.getLowerListener());
   this.higherTarget.removeMouseListener(this.getHigherListener());
   this.barTarget.removeMouseListener(this.getBarListener());
   target.removeScrollListener(this.scrollListener);
 }
  public void refresh() {
    int currentWidth = this.getOffsetWidth();

    float pageSize =
        (float) target.getOffsetWidth()
            / (float) (target.getMaxHorizontalScrollPosition() + target.getOffsetWidth());

    // GWT.log("Page sisze " + pageSize, null);
    float scrollPercentage =
        (float) target.getHorizontalScrollPosition()
            / (target.getMaxHorizontalScrollPosition() + 1);

    // GWT.log("Scroll Percentage " + scrollPercentage, null);
    int lowerWidth =
        Math.round((currentWidth - Math.round((float) currentWidth * pageSize)) * scrollPercentage);

    // GWT.log("Lower width " + lowerWidth, null);
    if (lowerWidth == 0) {
      lowerWidth = 1;
    }

    this.lower.setWidth(lowerWidth + "px");

    int barWidth = Math.round(currentWidth * pageSize);
    // GWT.log("Bar width " + barWidth, null);
    if (barWidth >= 0) {
      this.bar.setWidth(barWidth + "px");
    }
    int higherWidth = currentWidth - lowerWidth - barWidth;
    if (higherWidth >= 0) {
      this.higher.setWidth(higherWidth + "px");
    }
    this.lower.setHeight(this.getOffsetHeight() + "px");
    this.bar.setHeight(this.getOffsetHeight() + "px");
    this.higher.setHeight(this.getOffsetHeight() + "px");
  }
  protected void onAttach() {
    super.onAttach();
    target.addScrollListener(this.scrollListener);
    Window.addWindowResizeListener(this.windowListener);
    this.lowerTarget.addMouseListener(this.getLowerListener());
    this.higherTarget.addMouseListener(this.getHigherListener());
    this.barTarget.addMouseListener(this.getBarListener());

    Timer t =
        new Timer() {
          public void run() {
            target.setScrollPosition(target.getScrollPosition());
            refresh();
          }
        };

    t.schedule(10);
  }