JavaFX 1.3: Binding improved
Binding is one of the biggest strengths of JavaFX. I really like that.
And now – with release 1.3 – it seems to work much better. At least some of the simplest cases now work as expected.
The main difference is, that now bindings are lazy by default. They are not evaluated every time a var has changed. This is a big performance improvement for many cases.
April 25th, 2010 at 22:53
[...] Johannes Schneider has done a bunch of posts recently, so I’ll just mention the titles here: ‘JavaFX: Creating custom controls – the right way‘, ‘JavaFX: Bounds by example‘, ‘JavaFX: Gotcha in skin assignment‘ and ‘JavaFX 1.3: Binding improved‘. [...]
May 12th, 2010 at 05:00
There is a binding bug which seems to be related to whether you bind with inverse directly to the variable or whether you are accessing the variable through a path
This code snippet works fine with bind with inverse
var x=”text string”;
def cb = ChoiceBox{items: ["String 1","String 2"]};
var tb = TextBox{text:bind x with inverse};
var choice = bind cb.selectedItem on replace {
x=cb.selectedItem.toString();
println(“{x}”);
}
Stage {
title: “Application title”
scene: Scene {
width: 250
height: 80
content: [
HBox{
content:[tb,cb]
}
]
}
}
However this one does NOT work! As I am doing a bind not on a direct variable. But via traversal of a object hierarchy!
class Container{
public var x=”";
};
def box = Container{};
box.x=”text string”;
var tb = TextBox{text:bind box.x with inverse};
def cb = ChoiceBox{items: ["String 1","String 2"]};
var choice = bind cb.selectedItem on replace {
box.x=cb.selectedItem.toString();
println(“{box.x}”);
}
Stage {
title: “Application title”
scene: Scene {
width: 250
height: 80
content: [
HBox{
content:[
tb,
cb
]
}
]
}
}
June 2nd, 2010 at 10:31
Thanks for your sample.
I will try it. Thanks.
June 8th, 2010 at 14:31
Yes, you are right. Looks like a nasty bug….