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.

Get Mastering JavaFX 10 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.