src/main/java/com/spinyowl/legui/component/misc/listener/component/TabKeyEventListener.java
private Component findPrevInParent(Component component, Component parent, Component prev) {
    if (parent == null) {
      return prev;
    }

    List<Component> childComponents = parent.getChildComponents();
    childComponents.sort(comparator);
    Collections.reverse(childComponents);

    int index = childComponents.indexOf(component);
    if (index != childComponents.size() - 1) {
      for (int i = index + 1; i < childComponents.size(); i++) {
        Component child = childComponents.get(i);
        if (!child.isVisible()) {
          continue;
        }
        if (!child.isEmpty()) {
          Component cprev = findPrevInChildComponents(child.getChildComponents(), prev);
          if (prev != cprev) {
            return cprev;
          }
        } else if (isFF(child)) {
          return child;
        }
      }
      prev = findPrevInParent(parent, parent.getParent(), prev);
    } else if (isFF(parent)) {
      return parent;
    } else {
      prev = findPrevInParent(parent, parent.getParent(), prev);
    }
    return prev;
  }
/**
   * Used to find previous component in parent (in neighbors).
   *
   * @param component current component.
   * @param parent    parent component.
   * @param prev      current previous component.
   * @return previous component.
   */
Used to find previous component in parent (in neighbors).
@param component current component.
@param parent    parent component.
@param prev      current previous component.
@return previous component.
Used to find previous component in parent ( in neighbors ) . @param component current component . @param parent parent component . @param prev current previous component . @return previous component .
private Component findPrevInParent(Component component, Component parent, Component prev) {
    if (parent == null) {
      return prev;
    }
    List<Component> childComponents = parent.getChildComponents();
    childComponents.sort(comparator);
    Collections.reverse(childComponents);
    int index = childComponents.indexOf(component);
    if (index != childComponents.size() - 1) {
      for (int i = index + 1; i < childComponents.size(); i++) {
        Component child = childComponents.get(i);
        if (!child.isVisible()) {
          continue;
        }
        if (!child.isEmpty()) {
          Component cprev = findPrevInChildComponents(child.getChildComponents(), prev);
          if (prev != cprev) {
            return cprev;
          }
        } else if (isFF(child)) {
          return child;
        }
      }
      prev = findPrevInParent(parent, parent.getParent(), prev);
    } else if (isFF(parent)) {
      return parent;
    } else {
      prev = findPrevInParent(parent, parent.getParent(), prev);
    }
    return prev;
  }
private Component findPrevInParent ( Component component , Component parent , Component prev ) { if ( parent == null ) { return prev ; } List < Component > childComponents = parent . getChildComponents ( ) ; childComponents . sort ( comparator ) ; Collections . reverse ( childComponents ) ; int index = childComponents . indexOf ( component ) ; if ( index != childComponents . size ( ) - 1 ) { for ( int i = index + 1 ; i < childComponents . size ( ) ; i ++ ) { Component child = childComponents . get ( i ) ; if ( ! child . isVisible ( ) ) { continue ; } if ( ! child . isEmpty ( ) ) { Component cprev = findPrevInChildComponents ( child . getChildComponents ( ) , prev ) ; if ( prev != cprev ) { return cprev ; } } else if ( isFF ( child ) ) { return child ; } } prev = findPrevInParent ( parent , parent . getParent ( ) , prev ) ; } else if ( isFF ( parent ) ) { return parent ; } else { prev = findPrevInParent ( parent , parent . getParent ( ) , prev ) ; } return prev ; }
Used to find previous component in parent (in neighbors).
Used to find previous component in parent ( in neighbors ) .