Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #32499
| From | Jeff Higgins <jeff@invalid.invalid> |
|---|---|
| Newsgroups | comp.lang.c, comp.lang.java.programmer |
| Subject | Re: Self-updating relationship |
| Date | 2015-09-03 13:03 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <ms9ugt$163$1@dont-email.me> (permalink) |
| References | (6 earlier) <ms8g5j$o5k$1@dont-email.me> <ms9llv$pto$1@dont-email.me> <ms9mpb$srk$1@dont-email.me> <ms9p30$8vc$1@dont-email.me> <ms9rm4$ki2$1@dont-email.me> |
Cross-posted to 2 groups.
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<T> interface, rather than a property of
> the javafx.beans.binding.Binding<T> 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<T> while
> javafx.beans.property.SimpleIntegerProperty uses
> javafx.beans.binding.Binding<T>? 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
<https://docs.oracle.com/javase/8/javafx/api/index.html?overview-summary.html>
No frames
<https://docs.oracle.com/javase/8/javafx/api/overview-summary.html>
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<T> interface. IntegerPropertyBase is where the
Property.bind(ObservableValue<? extends T> observable) and
Property.unbind() are implemented.
The expression height.subtract(number) creates an
ObservableValue<Number>, 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.
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