Displaying changing values in JavaFx Label

后端 未结 4 1017
一生所求
一生所求 2020-11-30 05:10

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

4条回答
  •  迷失自我
    2020-11-30 05:31

    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.

提交回复
热议问题