Module javafx.base
Package javafx.collections

## Interface ObservableList<E>

- Type Parameters:
    `E` - the list element type
  All Superinterfaces:
    `Collection<E>`, `Iterable<E>`, `List<E>`, `Observable`
  All Known Subinterfaces:
    `ObservableListValue<E>`, `WritableListValue<E>`
  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

  A list that allows listeners to track changes when they occur.
  Since:
    JavaFX 2.0
  See Also:
    `ListChangeListener`, `ListChangeListener.Change`

- - ### Method Summary

    Modifier and Type | Method | Description
    --- | --- | ---
    `boolean` | `addAll​(E... elements)` | A convenience method for var-arg addition of elements.
    `void` | `addListener​(ListChangeListener<? super E> listener)` | Add a listener to this observable list.
    `default FilteredList<E>` | `filtered​(Predicate<E> predicate)` | Creates a `FilteredList` wrapper of this list using the specified predicate.
    `void` | `remove​(int from, int to)` | A simplified way of calling `sublist(from, to).clear()`.
    `boolean` | `removeAll​(E... elements)` | A convenience method for var-arg usage of the `removeAll` method.
    `void` | `removeListener​(ListChangeListener<? super E> listener)` | Tries to remove a listener from this observable list.
    `boolean` | `retainAll​(E... elements)` | A convenience method for var-arg usage of the `retainAll` method.
    `boolean` | `setAll​(E... elements)` | Clears the ObservableList and adds all the elements passed as var-args.
    `boolean` | `setAll​(Collection<? extends E> col)` | Clears the ObservableList and adds all elements from the collection.
    `default SortedList<E>` | `sorted()` | Creates a `SortedList` wrapper of this list with the natural ordering.
    `default SortedList<E>` | `sorted​(Comparator<E> comparator)` | Creates a `SortedList` wrapper of this list using the specified comparator.

    - ### Methods inherited from interface java.util.Collection

      `parallelStream, removeIf, stream, toArray`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach`

    - ### 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 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 remove 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 convenience method for var-arg addition of elements.
      Parameters:
        `elements` - the elements to add
      Returns:
        true (as specified by Collection.add(E))

    - #### setAll

          boolean setAll​(E... elements)

      Clears the ObservableList and adds all the elements passed as var-args.
      Parameters:
        `elements` - the elements to set
      Returns:
        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 adds all elements from the collection.
      Parameters:
        `col` - the collection with elements that will be added to this observableArrayList
      Returns:
        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 convenience method for var-arg usage of the `removeAll` method.
      Parameters:
        `elements` - the elements to be removed
      Returns:
        true if list changed as a result of this call

    - #### retainAll

          boolean retainAll​(E... elements)

      A convenience method for var-arg usage of the `retainAll` method.
      Parameters:
        `elements` - the elements to be retained
      Returns:
        true if list changed as a result of this call

    - #### remove

          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` - the start of the range to remove (inclusive)
        `to` - the end of the range to remove (exclusive)
      Throws:
        `IndexOutOfBoundsException` - if an illegal range is provided

    - #### filtered

          default FilteredList<E> filtered​(Predicate<E> predicate)

      Creates a `FilteredList` wrapper of this list using the specified predicate.
      Parameters:
        `predicate` - the predicate to use
      Returns:
        new `FilteredList`
      Since:
        JavaFX 8.0

    - #### sorted

          default SortedList<E> sorted​(Comparator<E> comparator)

      Creates a `SortedList` wrapper of this list using the specified comparator.
      Parameters:
        `comparator` - the comparator to use or null for unordered List
      Returns:
        new `SortedList`
      Since:
        JavaFX 8.0

    - #### sorted

          default SortedList<E> sorted()

      Creates a `SortedList` wrapper of this list with the natural ordering.
      Returns:
        new `SortedList`
      Since:
        JavaFX 8.0