Class ModifiableObservableListBase<E>
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- javafx.collections.ObservableListBase<E>
-
- javafx.collections.ModifiableObservableListBase<E>
Type Parameters:
E - the type of the elements contained in the List
All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>, Observable, ObservableList<E>
public abstract class ModifiableObservableListBase<E> extends ObservableListBase<E>
ObservableList implementations that are modifiable. To implement a modifiable ObservableList class, you just need to implement the following set of methods: and the notifications and built and fired automatically for you. Example of a simple ObservableList delegating to another List would look like this:
public class ArrayObservableList<E> extends ModifiableObservableList<E> {
private final List<E> delegate = new ArrayList<>();
public E get(int index) {
return delegate.get(index);
}
public int size() {
return delegate.size();
}
protected void doAdd(int index, E element) {
delegate.add(index, element);
}
protected E doSet(int index, E element) {
return delegate.set(index, element);
}
protected E doRemove(int index) {
return delegate.remove(index);
}
Since:
JavaFX 8.0
See Also:
-
Field Summary
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor and Description ModifiableObservableListBase()
-
Method Summary
All MethodsInstance MethodsAbstract MethodsConcrete Methods Modifier and Type Method and Description voidadd(int index, E element)booleanaddAll(Collection<? extends E> c)booleanaddAll(int index, Collection<? extends E> c)protected abstract voiddoAdd(int index, E element)Adds theelementto the List at the position ofindex.protected abstract EdoRemove(int index)Removes the element at position ofindex.protected abstract EdoSet(int index, E element)Sets theelementin the List at the position ofindex.abstract Eget(int index)Eremove(int index)booleanremove(Object o)booleanremoveAll(Collection<?> c)protected voidremoveRange(int fromIndex, int toIndex)booleanretainAll(Collection<?> c)Eset(int index, E element)booleansetAll(Collection<? extends E> col)Clears the ObservableList and add all elements from the collection.abstract intsize()List<E>subList(int fromIndex, int toIndex)-
Methods inherited from class javafx.collections.ObservableListBase
addAll, addListener, addListener, beginChange, endChange, fireChange, hasListeners, nextAdd, nextPermutation, nextRemove, nextRemove, nextReplace, nextSet, nextUpdate, remove, removeAll, removeListener, removeListener, retainAll, setAll
-
Methods inherited from class java.util.AbstractList
add, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator
-
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface javafx.collections.ObservableList
filtered, sorted, sorted
-
Methods inherited from interface java.util.List
add, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, replaceAll, sort, spliterator, toArray, toArray
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream
-
-
Constructor Detail
-
ModifiableObservableListBase
public ModifiableObservableListBase()
-
-
Method Detail
-
setAll
public boolean setAll(Collection<? extends E> col)
Description copied from interface:ObservableListClears the ObservableList and add all elements from the collection.Specified by:
setAllin interfaceObservableList<E>Overrides:
setAllin classObservableListBase<E>Parameters:
col- the collection with elements that will be added to this observableArrayListReturns:
true (as specified by Collection.add(E))
-
addAll
public boolean addAll(Collection<? extends E> c)
Specified by:
addAllin interfaceCollection<E>Overrides:
addAllin classAbstractCollection<E>
-
addAll
public boolean addAll(int index, Collection<? extends E> c)
-
removeRange
protected void removeRange(int fromIndex, int toIndex)Overrides:
removeRangein classAbstractList<E>
-
removeAll
public boolean removeAll(Collection<?> c)
Specified by:
removeAllin interfaceCollection<E>Overrides:
removeAllin classAbstractCollection<E>
-
retainAll
public boolean retainAll(Collection<?> c)
Specified by:
retainAllin interfaceCollection<E>Overrides:
retainAllin classAbstractCollection<E>
-
add
public void add(int index, E element)
-
set
public E set(int index, E element)
-
remove
public boolean remove(Object o)
Specified by:
removein interfaceCollection<E>Overrides:
removein classAbstractCollection<E>
-
remove
public E remove(int index)
-
subList
public List<E> subList(int fromIndex, int toIndex)
-
get
public abstract E get(int index)
-
size
public abstract int size()
Specified by:
sizein interfaceCollection<E>Specified by:
sizein classAbstractCollection<E>
-
doAdd
protected abstract void doAdd(int index, E element)Adds theelementto the List at the position ofindex.For the description of possible exceptions, please refer to the documentation of
AbstractList.add(java.lang.Object)method.Parameters:
index- the position where to add the elementThrows:
-
doSet
protected abstract E doSet(int index, E element)Sets theelementin the List at the position ofindex.For the description of possible exceptions, please refer to the documentation of
set(int, java.lang.Object)method.Parameters:
index- the position where to set the elementReturns:
the old element at the specified position
Throws:
-
doRemove
protected abstract E doRemove(int index)
Removes the element at position ofindex.Parameters:
index- the index of the removed elementReturns:
the removed element
Throws:
IndexOutOfBoundsException- if the index is out of range (index < 0 || index >= size())
-
© 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.