Mastering JavaFX 10
上QQ阅读APP看书,第一时间看更新

Binding blocks setters

Once a property is bound, you can't set it directly. The following code will throw RuntimeExceptionLabel.text : A bound value cannot be set. Take a look at the following code snippet:

lblWidth.textProperty().bind(stage.widthProperty().asString());
lblWidth.setText("hi"); // exception

If you want to do it, you need to call unbind() first.