コード例 #1
0
 private void updateScrollButtons() {
   if (scrollButtonBox != null) {
     ScrollableBox scrollableBox = (ScrollableBox) componentContainer;
     scrollButtonBox.setButton1Enabled(!scrollableBox.isLeftEnd());
     scrollButtonBox.setButton2Enabled(!scrollableBox.isRightEnd());
   }
 }
コード例 #2
0
  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();
  }