Class Form.TabIterator

java.lang.Object
com.codename1.ui.Form.TabIterator
All Implemented Interfaces:
Iterator<Component>, ListIterator<Component>
Enclosing class:
Form

public static class Form.TabIterator extends Object implements ListIterator<Component>

Iterates through the components on this form in traversal order.

See also
  • #getTabIterator(com.codename1.ui.Component)
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a component to the end of the iterator.
    Gets the current component in this iterator.
    Gets the next component in this iterator.
    Gets the previous component that should be traversed when going "back" in through the form components.
    boolean
    Checks to see if there is a "next" component to traverse focus to in this iterator.
    boolean
    Checks if this iterator has a "previous" component.
    Returns the next component in this iterator, and repositions the iterator at this component.
    int
    Gets the index within the iterator of the next component.
    Returns the previous component in this iterator, and repositions the iterator at this component.
    int
    Gets the index within the iterator of the previous component.
    void
    Removes the current component from the iterator, and repositions the iterator to the previous component, or the next component (if previous doesn't exist).
    void
    Replaces the current component, in the iterator, with the provided component.
    void
    Sets the current component in the iterator.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getCurrent

      public Component getCurrent()
      Gets the current component in this iterator.
    • setCurrent

      public void setCurrent(Component cmp)

      Sets the current component in the iterator. This reposition the iterator to the given component.

      Parameters
      • cmp: The component to set as the current component.
    • getNext

      public Component getNext()

      Gets the next component in this iterator. If the current component explicitly specifies a nextFocusRight or nextFocusDown component, then that component will be returned. Otherwise it will follow the tab index order.

      Returns

      The next component to be traversed after #getCurrent()

    • getPrevious

      public Component getPrevious()

      Gets the previous component that should be traversed when going "back" in through the form components. If the current component has a nextFocusLeft or nextFocusUp field explicitly specified, then it will return that. Otherwise it just follows the traversal order using the tab index.

      Returns

      The previous component according to traversal order.

    • hasNext

      public boolean hasNext()

      Checks to see if there is a "next" component to traverse focus to in this iterator.

      Returns

      True if there is a "next" component in this iterator.

      Specified by:
      hasNext in interface Iterator<Component>
      Specified by:
      hasNext in interface ListIterator<Component>
      Returns:
      true if there are more elements, false otherwise.
      See Also:
    • next

      public Component next()

      Returns the next component in this iterator, and repositions the iterator at this component.

      Returns

      The "next" component in the iterator.

      Specified by:
      next in interface Iterator<Component>
      Specified by:
      next in interface ListIterator<Component>
      Returns:
      the next object.
      See Also:
    • hasPrevious

      public boolean hasPrevious()
      Checks if this iterator has a "previous" component.
      Specified by:
      hasPrevious in interface ListIterator<Component>
      Returns:
      true if there are previous elements, false otherwise.
      See Also:
    • previous

      public Component previous()
      Returns the previous component in this iterator, and repositions the iterator at this component.
      Specified by:
      previous in interface ListIterator<Component>
      Returns:
      the previous object.
      See Also:
    • nextIndex

      public int nextIndex()
      Gets the index within the iterator of the next component.
      Specified by:
      nextIndex in interface ListIterator<Component>
      Returns:
      the index of the next object, or the size of the list if the iterator is at the end.
      See Also:
    • previousIndex

      public int previousIndex()
      Gets the index within the iterator of the previous component.
      Specified by:
      previousIndex in interface ListIterator<Component>
      Returns:
      the index of the previous object, or -1 if the iterator is at the beginning.
      See Also:
    • remove

      public void remove()
      Removes the current component from the iterator, and repositions the iterator to the previous component, or the next component (if previous doesn't exist).
      Specified by:
      remove in interface Iterator<Component>
      Specified by:
      remove in interface ListIterator<Component>
    • set

      public void set(Component e)

      Replaces the current component, in the iterator, with the provided component. This will not actually replace the component in the form's hierarchy. Just within the iterator.

      Parameters
      • e: The component to set as the current component.
      Specified by:
      set in interface ListIterator<Component>
      Parameters:
      e - the object to set.
    • add

      public void add(Component e)

      Adds a component to the end of the iterator.

      Parameters
      • e: The component to add to the iterator.
      Specified by:
      add in interface ListIterator<Component>
      Parameters:
      e - the object to insert.