Top Description Methods
javafx.collections

public Interface ObservableList<E>

extends List<E>, Observable
Known Direct Subinterfaces
com.sun.javafx.collections.SortableList, javafx.beans.value.ObservableListValue, javafx.beans.value.WritableListValue
Known Direct Implementers
javafx.collections.ObservableListBase, com.sun.javafx.collections.ImmutableObservableList, com.sun.javafx.collections.VetoableListDecorator, javafx.collections.FXCollections.EmptyObservableList, javafx.collections.FXCollections.SingletonObservableList, javafx.collections.FXCollections.SynchronizedObservableList
Type Parameters
<E>
the list element type
Imports
java.text.Collator, java.util.Collection, .Comparator, .List, java.util.function.Predicate, javafx.beans.Observable, javafx.collections.transformation.FilteredList, .SortedList

A list that allows listeners to track changes when they occur. Implementations can be created using methods in FXCollections such as observableArrayList, or with a SimpleListProperty.
Since
JavaFX 2.0
See Also
ListChangeListener, ListChangeListener.Change

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true (as specified by Collection.add(E))
addAll
(E...
the elements to add
elements
)

A convenience method for var-arg addition of elements.

public void
addListener(ListChangeListener<? super E>
the listener for listening to the list changes
listener
)

Add a listener to this observable list.

public default FilteredList<E>

Returns:

new FilteredList
filtered
(Predicate<E>
the predicate to use
predicate
)

Creates a FilteredList wrapper of this list using the specified predicate.

public void
remove(int
the start of the range to remove (inclusive)
from
,
int
the end of the range to remove (exclusive)
to
)

A simplified way of calling sublist(from, to).clear().

public boolean

Returns:

true if list changed as a result of this call
removeAll
(E...
the elements to be removed
elements
)

A convenience method for var-arg usage of the removeAll method.

public void
removeListener(ListChangeListener<? super E>
a listener to remove
listener
)

Tries to remove a listener from this observable list.

public boolean

Returns:

true if list changed as a result of this call
retainAll
(E...
the elements to be retained
elements
)

A convenience method for var-arg usage of the retainAll method.

public boolean

Returns:

true (as specified by Collection.add(E))
setAll
(E...
the elements to set
elements
)

Clears the ObservableList and adds all the elements passed as var-args.

public boolean

Returns:

true (as specified by Collection.add(E))
setAll
(Collection<? extends E>
the collection with elements that will be added to this observableArrayList
col
)

Clears the ObservableList and adds all elements from the collection.

public default SortedList<E>

Returns:

new SortedList
sorted
(Comparator<E>
the comparator to use or null for unordered List
comparator
)

Creates a SortedList wrapper of this list using the specified comparator.

public default SortedList<E>

Returns:

new SortedList
sorted
()

Creates a SortedList wrapper of this list with the natural ordering.

Inherited from java.util.List:
addaddaddAlladdAlladdFirstaddLastclearcontainscontainsAllcopyOfequalsgetgetFirstgetLasthashCodeindexOfisEmptyiteratorlastIndexOflistIteratorlistIteratorofofofofofofofofofofofofremoveremoveremoveAllremoveFirstremoveLastreplaceAllretainAllreversedsetsizesortspliteratorsubListtoArraytoArray
Inherited from javafx.beans.Observable:
addListenerremoveListenersubscribe

Method Detail

addAllback to summary
public boolean addAll(E... elements)

A convenience method for var-arg addition of elements.

Parameters
elements:E[]

the elements to add

Returns:boolean

true (as specified by Collection.add(E))

addListenerback to summary
public void addListener(ListChangeListener<? super E> listener)

Add a listener to this observable list.

Parameters
listener:ListChangeListener<? super E>

the listener for listening to the list changes

filteredback to summary
public default FilteredList<E> filtered(Predicate<E> predicate)

Creates a FilteredList wrapper of this list using the specified predicate.

Parameters
predicate:Predicate<E>

the predicate to use

Returns:FilteredList<E>

new FilteredList

Since
JavaFX 8.0
removeback to summary
public void remove(int from, int to)

A simplified way of calling sublist(from, to).clear(). As this is a common operation, ObservableList has this method for convenient usage.

Parameters
from:int

the start of the range to remove (inclusive)

to:int

the end of the range to remove (exclusive)

Exceptions
IndexOutOfBoundsException:
if an illegal range is provided
removeAllback to summary
public boolean removeAll(E... elements)

A convenience method for var-arg usage of the removeAll method.

Parameters
elements:E[]

the elements to be removed

Returns:boolean

true if list changed as a result of this call

removeListenerback to summary
public void removeListener(ListChangeListener<? super E> listener)

Tries to remove a listener from this observable list. If the listener is not attached to this list, nothing happens.

Parameters
listener:ListChangeListener<? super E>

a listener to remove

retainAllback to summary
public boolean retainAll(E... elements)

A convenience method for var-arg usage of the retainAll method.

Parameters
elements:E[]

the elements to be retained

Returns:boolean

true if list changed as a result of this call

setAllback to summary
public boolean setAll(E... elements)

Clears the ObservableList and adds all the elements passed as var-args.

Parameters
elements:E[]

the elements to set

Returns:boolean

true (as specified by Collection.add(E))

Exceptions
NullPointerException:
if the specified arguments contain one or more null elements
setAllback to summary
public boolean setAll(Collection<? extends E> col)

Clears the ObservableList and adds all elements from the collection.

Parameters
col:Collection<? extends E>

the collection with elements that will be added to this observableArrayList

Returns:boolean

true (as specified by Collection.add(E))

Exceptions
NullPointerException:
if the specified collection contains one or more null elements
sortedback to summary
public default SortedList<E> sorted(Comparator<E> comparator)

Creates a SortedList wrapper of this list using the specified comparator.

Parameters
comparator:Comparator<E>

the comparator to use or null for unordered List

Returns:SortedList<E>

new SortedList

Since
JavaFX 8.0
sortedback to summary
public default SortedList<E> sorted()

Creates a SortedList wrapper of this list with the natural ordering.

Returns:SortedList<E>

new SortedList

Since
JavaFX 8.0