Displaying changing values in JavaFx Label

Surjit picture Surjit · Nov 5, 2012 · Viewed 59.4k times · Source

In JavaFX, how can I display values which continuously change with time using "label" ?

Answer

zhujik picture zhujik · Nov 5, 2012

There are numerous ways to achieve that, the most convenient would be to use JavaFX's DataBinding mechanism:

// assuming you have defined a StringProperty called "valueProperty"
Label myLabel = new Label("Start");
myLabel.textProperty().bind(valueProperty);

This way, every time your valueProperty gets changed by calling it's set method, the label's text is updated.