-
Bug
-
Resolution: Unresolved
-
P3
-
8, 9
-
Windows 7 64-bit
Adding a second listener to the Java SimpleMapProperty causes neither one to respond.
import javafx.beans.property.MapProperty;
import javafx.beans.property.SimpleMapProperty;
import javafx.collections.FXCollections;
public final class MapPropertyInitialization {
public static void main(final String[] args) {
final MapProperty<String, String> mp =
new SimpleMapProperty<String, String>(
FXCollections.observableHashMap());
mp.addListener((obv1, ov1, nv1) -> {
System.out.format("1: mp: %s%n", nv1);
});
mp.put("key 1", "object 1");
mp.addListener((obv2, ov2, nv2) -> {
System.out.format("2: mp: %s%n", nv2);
});
mp.put("key 2", "object 2");
}
}
Should print:
1: mp: {key1=object1}
1: mp: {key2=object2, key1=object1}
2: mp: {key2=object2, key1=object1}
But only the first line shows up.
Adding an empty MapChangeListener corrects the problem.
mp.addListener(new MapChangeListener<String, String>() {
@Override
public void onChanged(Change<? extends String, ? extends String> map) {}
});
import javafx.beans.property.MapProperty;
import javafx.beans.property.SimpleMapProperty;
import javafx.collections.FXCollections;
public final class MapPropertyInitialization {
public static void main(final String[] args) {
final MapProperty<String, String> mp =
new SimpleMapProperty<String, String>(
FXCollections.observableHashMap());
mp.addListener((obv1, ov1, nv1) -> {
System.out.format("1: mp: %s%n", nv1);
});
mp.put("key 1", "object 1");
mp.addListener((obv2, ov2, nv2) -> {
System.out.format("2: mp: %s%n", nv2);
});
mp.put("key 2", "object 2");
}
}
Should print:
1: mp: {key1=object1}
1: mp: {key2=object2, key1=object1}
2: mp: {key2=object2, key1=object1}
But only the first line shows up.
Adding an empty MapChangeListener corrects the problem.
mp.addListener(new MapChangeListener<String, String>() {
@Override
public void onChanged(Change<? extends String, ? extends String> map) {}
});
- duplicates
-
JDK-8169052 ChangeListener not executed
- Closed
-
JDK-8173987 One and only one change listener works for MapPropertyBase<K,V>
- Closed
-
JDK-8177023 If multiple ChangeListener are added on ListProperty and one of them fail, others will not be fired
- Closed
- relates to
-
JDK-8089169 ListPropertyBase: must not fire changeEvent on modifying the list
- Open