public static class Form.TabIterator

  1. Object
  2. Form.TabIterator

ImplementsIterator<Component>, ListIterator<Component>

Iterates through the components on this form in traversal order.

See also

  • #getTabIterator(com.codename1.ui.Component)

Methods

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

Inherited methods

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 Component
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.

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.

hasPrevious

public boolean hasPrevious()
Checks if this iterator has a “previous” component.

Returns

true if there are previous elements, false otherwise.

previous

public Component previous()
Returns the previous component in this iterator, and repositions the iterator at this component.

Returns

the previous object.

Throws

NoSuchElementException
if there are no previous elements.

nextIndex

public int nextIndex()
Gets the index within the iterator of the next component.

Returns

the index of the next object, or the size of the list if the iterator is at the end.

Throws

NoSuchElementException
if there are no more elements.

previousIndex

public int previousIndex()
Gets the index within the iterator of the previous component.

Returns

the index of the previous object, or -1 if the iterator is at the beginning.

Throws

NoSuchElementException
if there are no previous elements.

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).

Throws

UnsupportedOperationException
if removing is not supported by the list being iterated.
IllegalStateException
if next or previous have not been called, or remove or add have already been called after the last call to next or previous.

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 Component
The component to set as the current component.

Throws

UnsupportedOperationException
if setting is not supported by the list being iterated
ClassCastException
if the class of the object is inappropriate for the list.
IllegalArgumentException
if the object cannot be added to the list.
IllegalStateException
if next or previous have not been called, or remove or add have already been called after the last call to next or previous.

add

public void add(Component e)
Adds a component to the end of the iterator.

Parameters

e Component
The component to add to the iterator.

Throws

UnsupportedOperationException
if adding is not supported by the list being iterated.
ClassCastException
if the class of the object is inappropriate for the list.
IllegalArgumentException
if the object cannot be added to the list.