Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #32472
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | James Kuyper <jameskuyper@verizon.net> |
| Newsgroups | comp.lang.c, comp.lang.java.programmer |
| Subject | Re: Self-updating relationship |
| Date | Wed, 02 Sep 2015 18:49:40 -0400 |
| Organization | Self |
| Lines | 65 |
| Message-ID | <55E77D04.6080200@verizon.net> (permalink) |
| References | <relationship-20150902211808@ram.dialup.fu-berlin.de> <55E766BD.3060303@verizon.net> <spaces-20150902222406@ram.dialup.fu-berlin.de> |
| 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="13300"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+OhnCb4ikIygR3Asf1f0bnk7oFY3Xsyzs=" |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 |
| In-Reply-To | <spaces-20150902222406@ram.dialup.fu-berlin.de> |
| Cancel-Lock | sha1:ab5UzF8/X+l73C282Tszq8pddU8= |
| Xref | csiph.com comp.lang.c:69041 comp.lang.java.programmer:32472 |
Cross-posted to 2 groups.
Show key headers only | View raw
On 09/02/2015 05:25 PM, Stefan Ram wrote:
> James Kuyper <jameskuyper@verizon.net> writes:
>>> final javafx.beans.property.IntegerProperty height
>>> = new javafx.beans.property.SimpleIntegerProperty( 10 );
>>> final javafx.beans.property.IntegerProperty number
>>> = new javafx.beans.property.SimpleIntegerProperty( 2 );
>>> final javafx.beans.binding.NumberBinding spaces =
>>> height.subtract( number );
>>> java.lang.System.out.println( spaces.getValue() );
>>> height.set( 20 );
>>> java.lang.System.out.println( spaces.getValue() ); }}
>> What's the java feature that makes "spaces" above update automatically?
>> To put it another way - if I didn't want such updates, what should I
>> write differently?
>
> This depends on the details of the behavior you want instead.
I read a bit about Java many years ago, and reached the conclusion that
it had some syntactic similarities C++, but had a very different way of
implementing objects. I played with it long enough to get something
working, but concluded that it wasn't what I needed for any purpose I
was trying to achieve at the time. I'm otherwise very unfamiliar with java.
I get the impression from what you're saying, that the code you've shown
results in each call to spaces.getValue() performing a fresh calculation
of height-number, using the values of those things at the time
getValue() is called. I'm asking about what you would have to do
differently to have spaces set to the value of height - number at one
particular time, and to have spaces.getValue() continue to report that
same value, even if the values of height and number later change. It
seems to me that this should be easier than arranging for automatic
updates - in fact, I'd expect it to be trivial.
> For one example, you can simply omit »height.set( 20 )«, and
> »spaces« will not be updated. Or, you could just write:
Well, I'm asking how to ensure that "spaces" will not be updated, even
if "height" is, so that doesn't qualify.
> public final class Main
> { public static void main( final java.lang.String[] args )
> { final javafx.beans.property.IntegerProperty spaces
> = new javafx.beans.property.SimpleIntegerProperty( 8 );
> java.lang.System.out.println( spaces.getValue() ); }}
>
> Which just will print »8« and not update spaces, or just
>
> public final class Main
> { public static void main( final java.lang.String[] args )
> { int const spaces = 8; java.lang.System.out.println( spaces ); }}
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.
> or just,
>
> public final class Main
> { public static void main( final java.lang.String[] args )
> { java.lang.System.out.println( 8 ); }}
>
> to get the same behavior.
That seems to print out 8 without even storing it anywhere, and without
any connection to "height" or "number".
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Self-updating relationship James Kuyper <jameskuyper@verizon.net> - 2015-09-02 17:14 -0400
Re: Self-updating relationship Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-09-02 17:46 -0400
Re: Self-updating relationship Arne Vajhøj <arne@vajhoej.dk> - 2015-09-03 21:06 -0400
Re: Self-updating relationship e.d.programmer@gmail.com - 2015-09-04 04:46 -0700
Re: Self-updating relationship Arne Vajhøj <arne@vajhoej.dk> - 2015-09-04 19:43 -0400
Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-04 11:49 -0400
Re: Self-updating relationship Arne Vajhøj <arne@vajhoej.dk> - 2015-09-04 19:45 -0400
Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-04 22:10 -0400
Re: Self-updating relationship Arne Vajhøj <arne@vajhoej.dk> - 2015-09-04 22:31 -0400
Re: Self-updating relationship Arne Vajhøj <arne@vajhoej.dk> - 2015-09-04 22:38 -0400
Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-04 22:51 -0400
Re: Self-updating relationship James Kuyper <jameskuyper@verizon.net> - 2015-09-02 18:49 -0400
Re: Self-updating relationship James Kuyper <jameskuyper@verizon.net> - 2015-09-02 19:28 -0400
Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-02 23:52 -0400
Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-03 10:32 -0400
Re: Self-updating relationship James Kuyper <jameskuyper@verizon.net> - 2015-09-03 10:53 -0400
Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-03 11:31 -0400
Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-03 11:35 -0400
Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-03 11:49 -0400
Re: Self-updating relationship James Kuyper <jameskuyper@verizon.net> - 2015-09-03 12:16 -0400
Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-03 13:03 -0400
Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-03 10:55 -0400
Re: Self-updating relationship James Kuyper <jameskuyper@verizon.net> - 2015-09-03 00:06 -0400
Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-02 23:38 -0400
Re: Self-updating relationship Jeff Higgins <jeff@invalid.invalid> - 2015-09-03 01:22 -0400
csiph-web