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.


4 Responses to “JavaFX 1.3: Binding improved”

  • JavaFX links of the week, April 25 // JavaFX News, Demos and Insight // FX Experience Says:

    [...] 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‘. [...]

  • Dhruva Ray Says:

    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
    ]
    }
    ]
    }
    }

  • johannes Says:

    Thanks for your sample.
    I will try it. Thanks.

  • johannes Says:

    Yes, you are right. Looks like a nasty bug….

Leave a Reply