Force immediate paint in JavaFX

前端 未结 3 450
耶瑟儿~
耶瑟儿~ 2021-01-12 10:13

Is there a way to force a JavaFX app to repaint itself before proceeding? Similar to a Swing Panel\'s paint(Graphic g) method (I might be getting the keywords wrong there).<

3条回答
  •  天命终不由人
    2021-01-12 10:34

    You are right. JavaFX is event-driven and single-threaded. This means that repaint and event response can not be done simultaneously. Long-running task should be executed on separate thread so they do not block the rendering of the UI, When the task is finished it can sync back to the FX thread by calling FX.deferAction() which will simply execute the code on the main thread.

提交回复
热议问题