Java Reference
In-Depth Information
Understanding ObservableSet
The ObservableSet interface is similar to the ObservableMap interface in that its SetChangeListener.Change object
tracks a single element. Figure 7-3 is a UML diagram showing the ObservableSet and supporting interfaces.
Figure 7-3. Key interfaces that support the JavaFX observable set
To prevent clutter, we omitted the java.util.Set interface from the diagram in Figure 7-3 . The java.util.Set
interface is the other super interface of ObservableSet . The following methods on the ObservableSet interface allow
you to register and unregister SetChangeListeners :
addListener(SetChangeListener<? super E> listener)
addListener(SetChangeListener<? super E> listener)
There are no additional convenience methods on ObservableSet .
The SetChangeListener interface has only one method: onChange(SetChangeListener.Change<? extends
E> change) . This method is called back when the content of the ObservableSet is manipulated. Notice that this
method's parameter type is the nested class Change that is declared in the SetChangeListener interface. The
SetChangeListener.Change class is geared toward reporting the change of a single element in a set. If a method call on
ObservableSet affects multiple elements, as many set change events as the number of affected elements will be fired.
The SetChangeListener.Change class provides the following methods for you to inspect the changes made
to an element.
 
Search WWH ::




Custom Search