Path: csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: James Kuyper Newsgroups: comp.lang.c,comp.lang.java.programmer Subject: Re: Self-updating relationship Date: Wed, 02 Sep 2015 19:28:54 -0400 Organization: Self Lines: 33 Message-ID: <55E78636.5000908@verizon.net> References: <55E766BD.3060303@verizon.net> <55E77D04.6080200@verizon.net> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="39e08c8e41e420e151f672c73609c593"; logging-data="20544"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19p7C2PTjHPUu3IVrO3pB6XibEYn62M8E8=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 In-Reply-To: Cancel-Lock: sha1:T4+ZZiTXtomunW1U4f6Uj6nz2UM= Xref: csiph.com comp.lang.c:69047 comp.lang.java.programmer:32475 On 09/02/2015 07:13 PM, Stefan Ram wrote: > James Kuyper writes: >> Those both set spaces to 8, rather than height - number. If >> height-number is currently 8, that happens to be the right value, but >> isn't what I'm looking for. > > If you just want to set »spaces« to »height - number« once, > with no further update: ... > final javafx.beans.property.IntegerProperty spaces > = new javafx.beans.property.SimpleIntegerProperty > ( height.getValue() - number.getValue() ); So, using C++ as an analogy that I'm more familiar with, this constructs "spaces" as a SimpleIntegerProperty initialized with the value of that expression, which never gets re-evaluated. Your earlier version had: > final javafx.beans.binding.NumberBinding spaces = > height.subtract( number ); which causes spaces.getValue() to behave like the equivalent of a C++ member function whose return value is calculated using the specified formula freshly each time "spaces" is referred to. Is this a characteristic of binding.NumberBinding, or some more general Java feature? Have I got that right? In C++, the equivalent of the first form above would be simpler than the equivalent of the second form, so it feels odd that the second form is simpler in Java. I'll try to keep that in mind should I ever need to program in Java again. It sounds like I've got a lot to learn before I even get started.