问题描述
TextField customTextField
Label customLabel
我想将 customLabel
绑定到 customTextField
的 TextProperty。这样做之后,customLabel
将根据 customTextField
包含的内容进行更新。但是,我想要的远不止这些。例如,如果我输入金额 15.0
,我希望它将 customLabel
的文本更新为 15.0/100.0
。有没有办法做到这一点?
提前致谢。
解决方法
看起来您已经想通了,但是为了向任何可能来这里寻找的人澄清,您可以使用以下内容:
customLabel.textProperty().bind(
customTextField.textProperty().stringBinding { "$it/100.0" }
)