我想将文本节点的text属性绑定到两个属性,如下所示:
Text income = new Text();
income.textProperty().bind(Bindings.concat(Available.income.asString()).concat(" Income for ").concat(now.getValue().getMonth().toString()));
Run Code Online (Sandbox Code Playgroud)

现在,当Available.income更改时,Text节点反映更新,但'now'更改时没有任何反应;
public static SimpleIntegerProperty income = new SimpleIntegerProperty
private ObjectProperty<YearMonth> now = new SimpleObjectProperty<YearMonth>(YearMonth.now());
Run Code Online (Sandbox Code Playgroud)
我怎么能解决这个问题,谢谢
你可以做
income.textProperty().bind(Bindings.createStringBinding(() ->
available.income.get() + " Income for " + now.getValue().getMonth(),
available.income, now));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
857 次 |
| 最近记录: |