コード例 #1
0
  /** Moves focus to the first component in the next row. */
  protected void moveToNextRow() {
    if (Debug.ON) Logger.dev("OFocusManager.moveToNextRow CALLED ");

    int nextRank = focusedComponentIndex + 1;
    boolean moved = false;
    OFocusableComponent gainer = null;
    int lastRank = focusableComponents.size() - 1;
    if (nextRank <= lastRank) { // there are more components
      int currentY = focusedComponent.getY();
      boolean keepLooking = true;
      for (; keepLooking && nextRank <= lastRank; nextRank++) {
        OFocusableComponent nextComponent =
            (OFocusableComponent) focusableComponents.elementAt(nextRank);
        if (nextComponent.getY() > currentY) { // component is in a later row
          gainer = (OFocusableComponent) nextComponent;
          focusedComponentIndex = nextRank;
          keepLooking = false;
          moved = true;
        }
      }
    }
    if (moved) {
      moveFocus(gainer);
    } else // there is no next row
    {
      OHandset.beep();
    }

    if (Debug.ON) Logger.dev("OFocusManager.moveToNextRow EXITTING ");
  } // moveToNextRow
コード例 #2
0
  /** Moves focus to the last component in the previous row. */
  protected void moveToPreviousRow() {
    if (Debug.ON) Logger.dev("OFocusManager.moveToPreviousRow CALLED ");
    int priorRank = focusedComponentIndex - 1;
    boolean moved = false;
    OFocusableComponent gainer = null;
    int firstRank = 0;
    if (priorRank >= firstRank) { // there is a previous component
      int currentY = focusedComponent.getY();
      boolean keepLooking = true;
      for (; keepLooking && priorRank >= firstRank; priorRank--) {
        OComponent previousComponent = (OComponent) focusableComponents.elementAt(priorRank);
        if (previousComponent.getY() < currentY
            && previousComponent instanceof OFocusableComponent) {
          gainer = (OFocusableComponent) previousComponent;
          focusedComponentIndex = priorRank;
          keepLooking = false;
          moved = true;
        }
      }
    }

    if (moved) {
      moveFocus(gainer);
    } else // there is no prior row
    {
      OHandset.beep();
    }

    if (Debug.ON) Logger.dev("OFocusManager.moveToPreviousRow EXITTING ");
  } // moveToPreviousRow