# 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`
  `add(Component e)`
  Adds a component to the end of the iterator.
  `Component`
  `getCurrent()`
  Gets the current component in this iterator.
  `Component`
  `getNext()`
  Gets the next component in this iterator.
  `Component`
  `getPrevious()`
  Gets the previous component that should be traversed when going "back" in through the form components.
  `boolean`
  `hasNext()`
  Checks to see if there is a "next" component to traverse focus to in this iterator.
  `boolean`
  `hasPrevious()`
  Checks if this iterator has a "previous" component.
  `Component`
  `next()`
  Returns the next component in this iterator, and repositions the iterator at this component.
  `int`
  `nextIndex()`
  Gets the index within the iterator of the next component.
  `Component`
  `previous()`
  Returns the previous component in this iterator, and repositions the iterator at this component.
  `int`
  `previousIndex()`
  Gets the index within the iterator of the previous component.
  `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).
  `void`
  `set(Component e)`
  Replaces the current component, in the iterator, with the provided component.
  `void`
  `setCurrent(Component cmp)`
  Sets the current component in the iterator.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface Iterator

  `forEachRemaining`

- ## 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>`

  - ### 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>`

  - ### hasPrevious

    public boolean hasPrevious()
    Checks if this iterator has a "previous" component.
    Specified by:
      `hasPrevious` in interface `ListIterator<Component>`

  - ### 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>`

  - ### nextIndex

    public int nextIndex()
    Gets the index within the iterator of the next component.
    Specified by:
      `nextIndex` in interface `ListIterator<Component>`

  - ### previousIndex

    public int previousIndex()
    Gets the index within the iterator of the previous component.
    Specified by:
      `previousIndex` in interface `ListIterator<Component>`

  - ### 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>`

  - ### 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>`