Java Reference
In-Depth Information
sb.append("\t\tAffected range: [")
.append(change.getFrom())
.append(", ")
.append(change.getTo())
.append("]\n");
if (kind.equals("added") || kind.equals("replaced")) {
sb.append("\t\tAdded size: ")
.append(change.getAddedSize())
.append("\n");
sb.append("\t\tAdded sublist: ")
.append(change.getAddedSubList())
.append("\n");
}
if (kind.equals("removed") || kind.equals("replaced")) {
sb.append("\t\tRemoved size: ")
.append(change.getRemovedSize())
.append("\n");
sb.append("\t\tRemoved: ")
.append(change.getRemoved())
.append("\n");
}
if (kind.equals("permutated")) {
StringBuilder permutationStringBuilder = new StringBuilder("[");
for (int k = change.getFrom(); k < change.getTo(); k++) {
permutationStringBuilder.append(k)
.append("->")
.append(change.getPermutation(k));
if (k < change.getTo() - 1) {
permutationStringBuilder.append(", ");
}
}
permutationStringBuilder.append("]");
String permutation = permutationStringBuilder.toString();
sb.append("\t\tPermutation: ").append(permutation).append("\n");
}
}
return sb.toString();
}
}
}
In the preceding example, we triggered the four kinds of discrete changes in an observable list. Because no
methods on an
ObservableList
will trigger a permutation event, we used the
sort()
utility method from the
FXCollections
class to effect a permutation. We have more to say about
FXCollections
in a later section. We
triggered the replace event twice, once with
set()
, and once with
setAll()
. The nice thing about
setAll()
is that it
effectively does a
clear()
and an
addAll()
in one operation and generates only one change event.
Search WWH ::
Custom Search