Ska*_*pka 10 java binding javafx
我要绑定的JavaFX Label.textProperty与int价值.
我试过例如
Label.textProperty().bindBidirectional(new SimpleIntegerProperty(myInt),
new NumberStringConverter());
Run Code Online (Sandbox Code Playgroud)
要么
Label().textProperty().bindBidirectional(new SimpleIntegerProperty(myInt),
new DecimalFormat());
Run Code Online (Sandbox Code Playgroud)
但我总是得到NullPointerException.
我该如何解决?
Ita*_*iha 15
如果你有一个int,你可以从它创建一个SimpleIntegerProperty,然后使用asString()它:
label.textProperty().bind(new SimpleIntegerProperty(integer).asString());
Run Code Online (Sandbox Code Playgroud)
如果您有IntegerProperty,则可以直接使用它
label.textProperty().bind(integerProperty.asString());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14772 次 |
| 最近记录: |