Concurrency issues in JavaFX GUI Updater utility class

前端 未结 2 480
执笔经年
执笔经年 2021-01-03 15:17

I\'m building a GUI in JavaFX for a rather large Java project. This project has many different worker threads doing some heavy computations in the background and I\'m trying

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-03 15:53

    I believe this functionality can be achieved through the Task's messageProperty:

    public void handle(ActionEvent event) {
        ...
        JavaFXTest.this.lblState.textProperty().bind(testTask.messageProperty());
        ...
    }
    
    ...
    
    protected Void call() throws Exception {
        ...
        this.updateProgress(i, maxValue - 1);
        this.updateMessage("Hello " + i);
        ...
    }
    

提交回复
热议问题