6
我想将JavaFX Label.textProperty
与int
的值绑定。JavaFX绑定带int值的标签
我试过
Label.textProperty().bindBidirectional(new SimpleIntegerProperty(myInt),
new NumberStringConverter());
或
Label().textProperty().bindBidirectional(new SimpleIntegerProperty(myInt),
new DecimalFormat());
但我总是得到NullPointerException异常。
我该如何解决?
任何原因在Label上使用双向绑定? – ItachiUchiha
@IchichiUchiha可能是因为它允许提供一个'StringConverter'。我试过之前,我发现你可以使用'integerProperty.asString()'与单向绑定,正如你在答案中指出的那样。 – Ruben9922