private void updateScrollButtons() {
   if (scrollButtonBox != null) {
     ScrollableBox scrollableBox = (ScrollableBox) componentContainer;
     scrollButtonBox.setButton1Enabled(!scrollableBox.isLeftEnd());
     scrollButtonBox.setButton2Enabled(!scrollableBox.isRightEnd());
   }
 }
 public void setComponentDirection(Direction componentDirection) {
   if (componentDirection != this.componentDirection) {
     this.componentDirection = componentDirection;
     getDirectionLayout()
         .setDirection(
             componentDirection == Direction.UP
                 ? Direction.RIGHT
                 : componentDirection == Direction.LEFT
                     ? Direction.DOWN
                     : componentDirection == Direction.DOWN ? Direction.RIGHT : Direction.DOWN);
     if (scrollEnabled) {
       scrollButtonBox.setVertical(componentDirection.isHorizontal());
       ((ScrollableBox) componentContainer).setVertical(componentDirection.isHorizontal());
     }
   }
 }
  private void initialize() {
    if (componentContainer != null) remove(componentContainer);

    DirectionLayout layout = getDirectionLayout();
    layout.setCompressing(!scrollEnabled);

    if (scrollEnabled) {
      if (useDefaultScrollButtons)
        scrollButtonBox = new ScrollButtonBox(componentDirection.isHorizontal(), iconSize);
      else
        scrollButtonBox =
            new ScrollButtonBox(componentDirection.isHorizontal(), null, null, null, null);

      final ScrollableBox scrollableBox =
          new ScrollableBox(componentBox, componentDirection.isHorizontal(), scrollOffset);
      scrollableBox.setLayoutOrderList(layoutOrderList);
      scrollButtonBox.addListener(
          new ScrollButtonBoxListener() {
            public void scrollButton1() {
              scrollableBox.scrollLeft(1);
            }

            public void scrollButton2() {
              scrollableBox.scrollRight(1);
            }
          });

      scrollableBox.addComponentListener(
          new ComponentAdapter() {
            public void componentResized(ComponentEvent e) {
              scrollButtonBox.setButton1Enabled(!scrollableBox.isLeftEnd());
              scrollButtonBox.setButton2Enabled(!scrollableBox.isRightEnd());
            }
          });

      scrollButtonBox.setButton1Enabled(!scrollableBox.isLeftEnd());
      scrollButtonBox.setButton2Enabled(!scrollableBox.isRightEnd());

      scrollableBox.addScrollableBoxListener(
          new ScrollableBoxListener() {
            public void scrolledLeft(ScrollableBox box) {
              scrollButtonBox.setButton1Enabled(!box.isLeftEnd());
              scrollButtonBox.setButton2Enabled(true);
            }

            public void scrolledRight(ScrollableBox box) {
              scrollButtonBox.setButton1Enabled(true);
              scrollButtonBox.setButton2Enabled(!box.isRightEnd());
            }

            public void changed(ScrollableBox box) {
              fireChangedEvent();
            }
          });
      componentContainer = scrollableBox;
    } else {
      scrollButtonBox = null;
      componentContainer = componentBox;
    }

    componentContainer.setAlignmentY(0);
    add(componentContainer, BorderLayout.CENTER);

    revalidate();
  }