报错信息:
Exception in thread "Thread-" java.lang.IllegalStateException: Not on FX application thread; currentThread = Thread-
显示信息不在 FX application线程中,
原错误代码为:
...
@FXML
private Button showFile;
...
@FXML
public void onSaveFile(ActionEvent event) {
...
showFile.setText("文件接受完成");
...
}
正确的姿势
...
@FXML
private Button showFile;
...
@FXML
public void onSaveFile(ActionEvent event) {
...
Platform.runLater(()->{
showFile.setText("文件接受完成");
});
...
}