Example #1
0
 /**
  * Returns the previous component that should receive focus in this container given the current
  * focus owner. If the supplied current focus owner is null, the container should return its last
  * focusable component. If the container has no focusable components before the current focus, it
  * should call {@link #getPreviousFocus()} to search further up the hierarchy.
  */
 protected BComponent getPreviousFocus(BComponent current) {
   boolean foundCurrent = (current == null);
   for (int ii = getComponentCount() - 1; ii >= 0; ii--) {
     BComponent child = getComponent(ii);
     if (!foundCurrent) {
       if (child == current) {
         foundCurrent = true;
       }
       continue;
     }
     if (child.acceptsFocus()) {
       return child;
     }
   }
   return getPreviousFocus();
 }
Example #2
0
 /**
  * Returns the next component that should receive focus in this container given the current focus
  * owner. If the supplied current focus owner is null, the container should return its first
  * focusable component. If the container has no focusable components following the current focus,
  * it should call {@link #getNextFocus()} to search further up the hierarchy.
  */
 protected BComponent getNextFocus(BComponent current) {
   boolean foundCurrent = (current == null);
   for (int ii = 0, ll = getComponentCount(); ii < ll; ii++) {
     BComponent child = getComponent(ii);
     if (!foundCurrent) {
       if (child == current) {
         foundCurrent = true;
       }
       continue;
     }
     if (child.acceptsFocus()) {
       return child;
     }
   }
   return getNextFocus();
 }
Example #3
0
  /** Removes the child at a specific position from this container. */
  public void remove(int index) {
    BComponent child = getComponent(index);
    _children.remove(index);
    if (_layout != null) {
      _layout.removeLayoutComponent(child);
    }
    child.setParent(null);

    // if we're part of the hierarchy we call wasRemoved() on the
    // child now (which will be propagated to all of its children)
    if (isAdded()) {
      child.wasRemoved();
    }

    // we need to be relayed out
    invalidate();
  }
Example #4
0
  /**
   * Adds a child to this container at the specified position, with the specified layout
   * constraints.
   */
  public void add(int index, BComponent child, Object constraints) {
    if (_layout != null) {
      _layout.addLayoutComponent(child, constraints);
    }
    _children.add(index, child);
    child.setParent(this);

    // if we're already part of the hierarchy, call wasAdded() on our
    // child; otherwise when our parent is added, everyone will have
    // wasAdded() called on them
    if (isAdded()) {
      child.wasAdded();
    }

    // we need to be relayed out
    invalidate();
  }
Example #5
0
  // documentation inherited
  protected void renderComponent(Renderer renderer) {
    super.renderComponent(renderer);

    // render our children
    for (int ii = 0, ll = getComponentCount(); ii < ll; ii++) {
      getComponent(ii).render(renderer);
    }
  }
Example #6
0
  // documentation inherited
  public void setVisible(boolean visible) {
    super.setVisible(visible);

    // show or hide our children accordingly
    for (int ii = getComponentCount() - 1; ii >= 0; ii--) {
      getComponent(ii).setVisible(visible);
    }
  }
Example #7
0
  // documentation inherited
  public void setEnabled(boolean enabled) {
    super.setEnabled(enabled);

    // enable or disable our children accordingly
    for (int ii = getComponentCount() - 1; ii >= 0; ii--) {
      getComponent(ii).setEnabled(enabled);
    }
  }
Example #8
0
  // documentation inherited
  public void setAlpha(float alpha) {
    super.setAlpha(alpha);

    // set our children's alpha values accordingly
    for (int ii = getComponentCount() - 1; ii >= 0; ii--) {
      getComponent(ii).setAlpha(alpha);
    }
  }
Example #9
0
  // documentation inherited
  public BComponent getHitComponent(int mx, int my) {
    // if we're not within our bounds, we don't need to check our children
    if (super.getHitComponent(mx, my) != this) {
      return null;
    }

    // translate the coordinate into our children's coordinates
    mx -= _x;
    my -= _y;

    BComponent hit = null;
    for (int ii = getComponentCount() - 1; ii >= 0; ii--) {
      BComponent child = getComponent(ii);
      if ((hit = child.getHitComponent(mx, my)) != null) {
        return hit;
      }
    }
    return this;
  }
Example #10
0
  /** Removes the specified child from this container. */
  public void remove(BComponent child) {
    if (!_children.remove(child)) {
      // if the component was not our child, stop now
      return;
    }
    if (_layout != null) {
      _layout.removeLayoutComponent(child);
    }
    child.setParent(null);

    // if we're part of the hierarchy we call wasRemoved() on the
    // child now (which will be propagated to all of its children)
    if (isAdded()) {
      child.wasRemoved();
    }

    // we need to be relayed out
    invalidate();
  }
Example #11
0
  // documentation inherited
  protected void wasRemoved() {
    super.wasRemoved();

    // call wasRemoved() on all of our children
    applyOperation(
        new ChildOp() {
          public void apply(BComponent child) {
            child.wasRemoved();
          }
        });
  }
Example #12
0
  // documentation inherited
  protected void wasAdded() {
    super.wasAdded();

    // call wasAdded() on all of our existing children; if they are
    // added later (after we are added), they will automatically have
    // wasAdded() called on them at that time
    applyOperation(
        new ChildOp() {
          public void apply(BComponent child) {
            child.wasAdded();
          }
        });
  }
Example #13
0
    @Override // documentation inherited
    public BComponent getHitComponent(int mx, int my) {
      // if we're not within our bounds, we needn't check our target
      Insets insets = getInsets();
      if ((mx < _x + insets.left)
          || (my < _y + insets.bottom)
          || (mx >= _x + _width - insets.right)
          || (my >= _y + _height - insets.top)) {
        return null;
      }

      // translate the coordinate into our children's coordinates
      mx -= _x;
      my -= (_y + _offset);

      BComponent hit = null;
      for (int ii = 0, ll = getComponentCount(); ii < ll; ii++) {
        BComponent child = getComponent(ii);
        if ((hit = child.getHitComponent(mx, my)) != null) {
          return hit;
        }
      }
      return this;
    }