Exemplo n.º 1
0
 public void init() {
   s1 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, 255);
   s2 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 5, 0, 255);
   s3 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 10, 0, 255);
   add(s1);
   add(s2);
   add(s3);
   s1.addAdjustmentListener(this);
   s2.addAdjustmentListener(this);
   s3.addAdjustmentListener(this);
   addMouseMotionListener(this);
   /*	s1.addMouseMotionListener(this);
   s2.addMouseMotionListener(this);
   s3.addMouseMotionListener(this);*/
 }
  public void init() {

    int width = Integer.parseInt(getParameter("width"));
    int height = Integer.parseInt(getParameter("height"));
    vertSB = new Scrollbar(Scrollbar.VERTICAL, 0, 1, 0, height);

    horzSB = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, width);

    add(vertSB);
    add(horzSB);

    // register to receive adjustment events

    vertSB.addAdjustmentListener(this);
    horzSB.addAdjustmentListener(this);
    addMouseMotionListener(this);
  }
Exemplo n.º 3
0
  /**
   * Set either the horizontal or vertical scrollbar.
   *
   * @param orientation either Scrollbar.HORIZONTAL or Scrollbar.VERTICAL
   * @param scrollbar component.
   */
  public void setScrollbar(int orientation, Scrollbar scrollbar) {
    if (orientation == Scrollbar.HORIZONTAL) {
      hScroll = scrollbar;
    } else {
      vScroll = scrollbar;
    }

    scrollbar.addAdjustmentListener(this);
    updateScrollbars();
  }