-
Enhancement
-
Resolution: Unresolved
-
P5
-
8u40
-
Windows 8.1 x64, Netbeans 8.0.2 x64, JDK 8u40ea23b
The usage of SimpleMapProperty should be explained in the JavaDoc. If you only code like this, you don't know, that a "simple" Property won't create a backed Map for storing values.
If you code this:
MapProperty<Integer, String> map= new SimpleMapProperty<>();
you get an error if you try to put some items:
Exception in thread "main" java.lang.UnsupportedOperationException
at java.util.AbstractMap.put(AbstractMap.java:203)
at javafx.beans.binding.MapExpression.put(MapExpression.java:277)
This is because the default constructor of SimpleMapProperty doesn't create a backed map. Only a call to:
MapProperty<Integer, String> map= new SimpleMapProperty<>(FXCollections.observableHashMap());
will produce a valid SimpleMapProperty. But this isn't explained.
If you code this:
MapProperty<Integer, String> map= new SimpleMapProperty<>();
you get an error if you try to put some items:
Exception in thread "main" java.lang.UnsupportedOperationException
at java.util.AbstractMap.put(AbstractMap.java:203)
at javafx.beans.binding.MapExpression.put(MapExpression.java:277)
This is because the default constructor of SimpleMapProperty doesn't create a backed map. Only a call to:
MapProperty<Integer, String> map= new SimpleMapProperty<>(FXCollections.observableHashMap());
will produce a valid SimpleMapProperty. But this isn't explained.