現在有人說它不適合使用Platform.runLater()
從非JavaFX線程和Oracle站點更新UI引入綁定進度條更新的方式。在這裏我想更新一個標籤,所以這樣編碼它:Javafx在沒有直接調用的情況下從線程更新UI Platform.runLater
Task task = new Task() {
@Override
protected Object call() throws Exception {
int i = 0;
while (true) {
this.updateMessage("Count " + i);
System.out.println(i);
// Thread.sleep(10);
i++;
}
}
};
Thread t = new Thread(task);
lbStatus.textProperty().bind(task.messageProperty());
t.start();
它的工作原理。
我想知道是否夠好或者有其他方法可以考慮? 謝謝。
可能重複[Java UI在UI替代品上運行](http://stackoverflow.com/questions/27113633/java-fx-running-on-ui-alternatives) – javaHunter 2014-12-05 09:47:50