Does JavaFX lack a public Property.getObservable() method?
Martin Sladecek
martin.sladecek at oracle.com
Fri Sep 12 11:08:22 UTC 2014
Hi Randahl,
why don't you use bidirectional binding for this purpose?
-Martin
On 09/12/2014 01:04 PM, Randahl Fink Isaksen wrote:
> I have noticed the lack of a getObservable() method of the property class, and I have come across a use case which might justify such a method, so I would like to discuss whether posting a new Jira issue for this is justified.
>
> I have implemented a simple toggle button with two states, on and off. The toggle button has a SimpleBooleanProperty value, and when the user switches the toggle button the value is negated.
>
> Now, in some cases I would like to bind the valueProperty to some observable boolean in my app, so that whenever that observable boolean is true, the button reflects that by switching to on. However, the problem is that if I bind the SimpleObjectProperty value to an observable boolean value, and then click the button to toggle it, a JavaFX exception tells me that I cannot negate the boolean value, since it is now bound.
>
> In such cases, I think it makes sense to have my toggle button change the state of the value it is bound to instead. But since the SimpleBooleanProperty does not have a getObservable() method, I have no way of accessing the value observed.
>
> Does this justify adding a public getObservable method to class Property?
>
> Yours
>
> Randahl
>
>
>
More information about the openjfx-dev
mailing list