make JavaFX wait until Timeline finishes

做~自己de王妃 提交于 2019-12-01 19:24:24

Timeline.play() is asynchronous—it starts the animation in the background and returns immediately. There are several ways to achieve sequential execution. Which fits best depends on your use case.

  1. Use just one Timeline and move the KeyFrames from your second timeline to the first one, with adjusted start duration.
  2. Start the second timeline when the first one is finished: timeline1.setOnFinished(e -> timeline2.play()).
  3. If you can, use Transitions instead of Timelines and wrap them in a SequentialTransition.
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!