我得到以下错误:
线程"Thread-5“java.lang.IllegalStateException中的异常:不在FX应用程序线程上;currentThread =Thread-5
执行此语句时:
root.getChildren().add(carros); 相关的代码片段是:
public void createCar(String origem, String destino){
Group carros = new Group();
carro1 = new Rectangle(30,15,Color.DARKMAGENTA);
carros.getChildren().add(carro1);
root.getChildren().add(carros);
animate(carros, (origem+"->"+destino) );
} 发布于 2016-09-10 07:18:33
您正在尝试在与FX应用程序线程不同的线程中更改JavaFX元素。您可以使用
Platform.runLater(new Runnable(){
// place the code here, that you want to execute
});若要运行修改JavaFX元素的代码,请执行以下操作。关于这个问题的其他答案,见这里How to avoid Not on FX application thread; currentThread = JavaFX Application Thread error?。
https://stackoverflow.com/questions/39422477
复制相似问题