How to properly use the SimpleSetProprty?
Hi all,
I'm trying to use a SimpleSetProperty. As I understand yu documentation are supposed to be able to add an Eleent in this well, but I still get an Exception
[code]
Exception in the init of Application method
Exception in thread "main" java.lang.RuntimeException: Exception in the init of Application method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:398)
to com.sun.javafx.application.LauncherImpl.access$ 000 (LauncherImpl.java:47)
to com.sun.javafx.application.LauncherImpl$ 1.run(LauncherImpl.java:115)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.UnsupportedOperationException
at java.util.AbstractCollection.add(AbstractCollection.java:252)
at javafx.beans.binding.SetExpression.add(SetExpression.java:292)
to de.cmk.jfx.Test2$ NamedPolygon.addReachable (Test2.java:235)
at de.cmk.jfx.Test2.figureOutNeighbourhoods(Test2.java:162)
at de.cmk.jfx.Test2.loadContentFromYaml(Test2.java:95)
at de.cmk.jfx.Test2.init(Test2.java:40)
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:296)
... 3 more
[/ code]
I googled for but was not able to find examples with SimpleSetProperty.
can someone give me a sample of work so I could win a clue what I'm doing wrong?
Thaks a lot in advance and best regards
Malta
Yes, these builders are a bit confusing. Note that this applies to all classes of SimpleXXXProperty:
The idea is that, for most uses, the property will be part of an object (or bean). That is, you'll have something like:
public class MyBean { private SetPropertymySet ; // ... public final SetProperty mySetProperty() { return mySet ; } public final ObservableSet getMySet() { return mySet.get(); } public final void setMySet(ObservableSet mySet) { this.mySet.set(mySet); } }
So in this case the SetProperty belongs to an object of type MyBean and the "RIGHT" property name So that the reflection to play well with this property (i.e. for the library code to correctly find the methods mySetProperty, getMySet and setMySet), it must be initialized with a reference to its "bean owner" and his name. SimpleSetProperty (Object, String) constructor is designed to do this:
public class MyBean { private SetPropertymySet = new SimpleSetProperty<>(this, "mySet"); // ... }
In other words, the first argument to the constructor is not a reference to the wrapped set.
If you need something like
SetPropertysetProperty2 = new SimpleSetProperty<>(this, "lala", hset);
(even though I think you will spend in an ObservableSet
SetProperty
Tags: Java
Similar Questions
-
How to properly use the "blackberry.app.exit"/"swipemenu"?
Hello developers BB!
Can someone show me how to use this feature? I use a physical PlayBook.
I tried to use the following code:
The config.xml file have this feature:
But when touching, nothing happens.
The bbui.js is necessary?
Or I use the wrong library/code?
Also how to call an action by using the upper frame by scanning?
for example:
function something()
{
use the topswipe
blah blah blah, this is the case
}
Thanks in advance for answers!
Once more, I am so used to seeing the reference to the webworks.js file, I has not yet noticed that was missing in your sample.
You must include the library that defines the API blackberry.*. Here's how you do that: