Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Jeff Higgins Newsgroups: comp.lang.c,comp.lang.java.programmer Subject: Re: Self-updating relationship Date: Thu, 03 Sep 2015 13:03:47 -0400 Organization: A noiseless patient Spider Lines: 76 Message-ID: References: <55E766BD.3060303@verizon.net> <55E77D04.6080200@verizon.net> <55E78636.5000908@verizon.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 3 Sep 2015 17:03:25 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="a78aad8b483612fbf45d18e918df0cca"; logging-data="1219"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/EVIhXW9q2uY10Uevelh9uDBMT7dT5lys=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0 In-Reply-To: Cancel-Lock: sha1:L2NiaUQ3s2hV1oC628CIgRGtouc= Xref: csiph.com comp.lang.c:69164 comp.lang.java.programmer:32499 On 09/03/2015 12:16 PM, James Kuyper wrote: > OK - I thought I was beginning to understand what was going on, but now > I'm thoroughly confused. You're saying that this behavior (Specifically, > the behavior of re-calculating the subtraction each time > spaces.getValue() is used) is a property of the > javafx.beans.property.Property interface, rather than a property of > the javafx.beans.binding.Binding interface, despite the fact that it > happens when he uses javafx.beans.binding.NumberBinding, and doesn't > happen when he uses javafx.beans.property.SimpleIntegerProperty? > > How does that work? Does javafx.beans.binding.NumberBinding use > javafx.beans.property.Property while > javafx.beans.property.SimpleIntegerProperty uses > javafx.beans.binding.Binding? That's not at all what I would have > expected, based solely upon the names. > > Perhaps our discussion is going beside itself it the threads. I would like to use the example code that I posted elsewhere and neglect the javafx.beans.binding package, in particular the NumberBinding interface if that is acceptable. If so I will reproduce the example here. You'll need access to the JavaFX documentation, located here: With frames No frames import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; public class Main { public static void main(String[] args) { final IntegerProperty height = new SimpleIntegerProperty(); final IntegerProperty number = new SimpleIntegerProperty(); final IntegerProperty spaces = new SimpleIntegerProperty(); spaces.bind(height.subtract(number)); height.set(10); number.set(2); System.out.print(spaces.get()); // 8 spaces.unbind(); height.set(20); System.out.print(spaces.get()); // 8 } } Here spaces is a SimpleIntegerProperty, a subclass of IntegerPropertyBase which is an implementation of the Property interface. IntegerPropertyBase is where the Property.bind(ObservableValue observable) and Property.unbind() are implemented. The expression height.subtract(number) creates an ObservableValue, through NumberExpression ( so much for neglecting the javafx.beans.binding package) which IntegerPropertyBase uses to bind height and number to spaces as specified in his documentation. As I stated elsewhere, the plethora of mixin interfaces makes it difficult (for me) to discuss, but writing code that uses it is simple.