Module javafx.base
Package javafx.collections
Interface ObservableArray<T extends ObservableArray<T>>
- 
- Type Parameters:
- T- actual array instance type
 - All Superinterfaces:
- Observable
 - All Known Subinterfaces:
- ObservableFaceArray,- ObservableFloatArray,- ObservableIntegerArray
 - All Known Implementing Classes:
- ObservableArrayBase
 
 public interface ObservableArray<T extends ObservableArray<T>> extends Observable ObservableArrayis an array that allows listeners to track changes when they occur. In order to track changes, the internal array is encapsulated and there is no direct access available from the outside. Bulk operations are supported but they always do a copy of the data range. You can find them in subclasses as they deal with primitive arrays directly.Implementations have both capacity, which is internal array length, andsize. If size needs to be increased beyond capacity, the capacity increases to match that new size. UsetrimToSize()method to shrink it.- Since:
- JavaFX 8.0
- See Also:
- ArrayChangeListener
 
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddListener(ArrayChangeListener<T> listener)Add a listener to this observable array.voidclear()Empties the array by resizing it to 0.voidensureCapacity(int capacity)Grows the capacity of this array if the current capacity is less than givencapacity, does nothing if it already exceeds thecapacity.voidremoveListener(ArrayChangeListener<T> listener)Tries to remove a listener from this observable array.voidresize(int size)Sets new length of data in this array.intsize()Retrieves length of data in this array.voidtrimToSize()Shrinks the capacity to the current size of data in the array.- 
Methods inherited from interface javafx.beans.ObservableaddListener, removeListener
 
- 
 
- 
- 
- 
Method Detail- 
addListenervoid addListener(ArrayChangeListener<T> listener) Add a listener to this observable array.- Parameters:
- listener- the listener for listening to the array changes
- Throws:
- NullPointerException- if- listeneris- null
 
 - 
removeListenervoid removeListener(ArrayChangeListener<T> listener) Tries to remove a listener from this observable array. If the listener is not attached to this array, nothing happens.- Parameters:
- listener- a listener to remove
- Throws:
- NullPointerException- if- listeneris- null
 
 - 
resizevoid resize(int size) Sets new length of data in this array. This method grows capacity if necessary but never shrinks it. Resulting array will contain existing data for indexes that are less than the current size and zeroes for indexes that are greater than the current size.- Parameters:
- size- new length of data in this array
- Throws:
- NegativeArraySizeException- if size is negative
 
 - 
ensureCapacityvoid ensureCapacity(int capacity) Grows the capacity of this array if the current capacity is less than givencapacity, does nothing if it already exceeds thecapacity.- Parameters:
- capacity- the capacity of this array
 
 - 
trimToSizevoid trimToSize() Shrinks the capacity to the current size of data in the array.
 - 
clearvoid clear() Empties the array by resizing it to 0. Capacity is not changed.- See Also:
- trimToSize()
 
 - 
sizeint size() Retrieves length of data in this array.- Returns:
- length of data in this array
 
 
- 
 
-