0

タイマーがゼロに達したときにペインから要素、より具体的にはラベルとテキスト領域を削除しようとしています。ただし、タイマーが 0 に達し、このメソッドを呼び出すと、この例外が発生します。

Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Not on FX application thread; currentThread = AWT-EventQueue-0

コード:

ActionListener timeListener = new ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
    gameTime--;
    System.out.println(gameTime);
    if(gameTime == 0){
      endGame();
    }
  }
};

endGame() メソッド:

public void endGame(){
  timer.stop();
  System.out.println("Score: " + score);
view.gamePane.getChildren().removeAll(view.lblQuestion, view.tfAnswer);
}
4

1 に答える 1