Interface ObservableList<E>
Type Parameters:
E - the list element type
All Superinterfaces:
Collection<E>, Iterable<E>, List<E>, Observable
All Known Subinterfaces:
All Known Implementing Classes:
FilteredList, ListBinding, ListExpression, ListProperty, ListPropertyBase, ModifiableObservableListBase, ObservableListBase, ReadOnlyListProperty, ReadOnlyListPropertyBase, ReadOnlyListWrapper, SimpleListProperty, SortedList, TransformationList
public interface ObservableList<E> extends List<E>, Observable
Since:
JavaFX 2.0
See Also:
-
Method Summary
All MethodsInstance MethodsAbstract MethodsDefault Methods Modifier and Type Method and Description booleanaddAll(E... elements)A convenient method for var-arg adding of elements.voidaddListener(ListChangeListener<? super E> listener)Add a listener to this observable list.default FilteredList<E>filtered(Predicate<E> predicate)Creates aFilteredListwrapper of this list using the specified predicate.voidremove(int from, int to)Basically a shortcut to sublist(from, to).clear() As this is a common operation, ObservableList has this method for convenient usage.booleanremoveAll(E... elements)A convenient method for var-arg usage of removaAll method.voidremoveListener(ListChangeListener<? super E> listener)Tries to removed a listener from this observable list.booleanretainAll(E... elements)A convenient method for var-arg usage of retain method.booleansetAll(Collection<? extends E> col)Clears the ObservableList and add all elements from the collection.booleansetAll(E... elements)Clears the ObservableList and add all the elements passed as var-args.default SortedList<E>sorted()Creates aSortedListwrapper of this list with the natural ordering.default SortedList<E>sorted(Comparator<E> comparator)Creates aSortedListwrapper of this list using the specified comparator.-
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream
-
Methods inherited from interface javafx.beans.Observable
addListener, removeListener
-
-
Method Detail
-
addListener
void addListener(ListChangeListener<? super E> listener)
Add a listener to this observable list.Parameters:
listener- the listener for listening to the list changes
-
removeListener
void removeListener(ListChangeListener<? super E> listener)
Tries to removed a listener from this observable list. If the listener is not attached to this list, nothing happens.Parameters:
listener- a listener to remove
-
addAll
boolean addAll(E... elements)
A convenient method for var-arg adding of elements.Parameters:
elements- the elements to addReturns:
true (as specified by Collection.add(E))
-
setAll
boolean setAll(E... elements)
Clears the ObservableList and add all the elements passed as var-args.Parameters:
elements- the elements to setReturns:
true (as specified by Collection.add(E))
Throws:
NullPointerException- if the specified arguments contain one or more null elements
-
setAll
boolean setAll(Collection<? extends E> col)
Clears the ObservableList and add all elements from the collection.Parameters:
col- the collection with elements that will be added to this observableArrayListReturns:
true (as specified by Collection.add(E))
Throws:
NullPointerException- if the specified collection contains one or more null elements
-
removeAll
boolean removeAll(E... elements)
A convenient method for var-arg usage of removaAll method.Parameters:
elements- the elements to be removedReturns:
true if list changed as a result of this call
-
retainAll
boolean retainAll(E... elements)
A convenient method for var-arg usage of retain method.Parameters:
elements- the elements to be retainedReturns:
true if list changed as a result of this call
-
remove
void remove(int from, int to)Basically a shortcut to sublist(from, to).clear() As this is a common operation, ObservableList has this method for convenient usage.Parameters:
from- the start of the range to remove (inclusive)Throws:
IndexOutOfBoundsException- if an illegal range is provided
-
filtered
default FilteredList<E> filtered(Predicate<E> predicate)
Creates aFilteredListwrapper of this list using the specified predicate.Parameters:
predicate- the predicate to useReturns:
new
FilteredListSince:
JavaFX 8.0
-
sorted
default SortedList<E> sorted(Comparator<E> comparator)
Creates aSortedListwrapper of this list using the specified comparator.Parameters:
comparator- the comparator to use or null for the natural orderReturns:
new
SortedListSince:
JavaFX 8.0
-
sorted
default SortedList<E> sorted()
Creates aSortedListwrapper of this list with the natural ordering.Returns:
new
SortedListSince:
JavaFX 8.0
-
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.