javafx Bindings.createStringBinding but binding not actually work

前端 未结 1 534
长发绾君心
长发绾君心 2021-01-21 09:56

I\'m trying to bind the textProperty of the Label to the object\'s SimpleIntegerProperty with help of Bindings but it does no

1条回答
  •  再見小時候
    2021-01-21 10:25

    You need to "tell" Bindings, which Observables to observe for changes. This varargs parameter is the second parameter of the createStringBinding method. In this case you need to pass only a single Observable: object.numberProperty()

    label.textProperty().bind(
       Bindings.createStringBinding(
          () -> " hello " + object.numberProperty().get() * (10 + 12)/2,
          object.numberProperty()));
    

    0 讨论(0)
提交回复
热议问题