gpt4 book ai didi

JavaFX - 刷新标签

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:14:50 24 4
gpt4 key购买 nike

<分区>

你能解释一下如何刷新 Label 中的值吗?

在初始化时,我将 Label 的文本绑定(bind)到 StringProperty。这里没问题。

我有 Button,在按下按钮时我想在每个迭代步骤中更新 Label 值。但我只能看到最终值(value)。为什么?

@FXML
private Label label;

@FXML
private void handleButtonAction(ActionEvent event) throws InterruptedException {
for(int i=0;i<1001;i++){

try {
Thread.sleep(1);
} catch (InterruptedException ie) {
//Handle exception
}
this.value.setValue(i+"");
}
}

// Bind
private StringProperty value = new SimpleStringProperty("0");

@Override
public void initialize(URL url, ResourceBundle rb) {
// Bind label to value.
this.label.textProperty().bind(this.value);
}

24 4 0