JavaFX为什么AnimationTimer没有getStatus()或类似的方法? [英] JavaFX Why AnimationTimer has not getStatus() or similar method?
问题描述
AnimationTimer 没有一种方法可以知道它是否正在运行....我正面临这个问题,因为有时它会启动,有时候不会。
It seems pretty strange that AnimationTimer has not a method to know if it is running or not.... And i am facing this problem, cause sometimes it is starting and sometimes not.
解决方案在 handle()
方法中创建 volatile变量
,并且每次在句柄内运行时都将其设置为true每次进入 stop()
)方法使其成为假。所以我必须 @Override
这两种方法。
A solution is creating a volatile variable
inside the handle()
method and every time it is running inside the handle to make it true and every time it enters stop()
) method to make it false.So i have to @Override
both methods.
问题:
为什么 AnimationTimer
没有确定它是否正在运行的方法?
Why the AnimationTimer
has not a method to determine if it is running?
这是一个糟糕的设计吗?由于某种原因缺失?
Is it a bad design it is missing for some reason?
相关问题:
< a href =https://stackoverflow.com/questions/33068953/is-animationtimer-run-in-its-own-thread#3 3069184> AnimationTimer是否在自己的线程中运行?
推荐答案
确实很奇怪,这种方法很缺失,但除了你和我之外,似乎没有人关心。我已经在4年多前报告了这个问题
,从那时起没有发生任何事情,虽然修复似乎是微不足道的。
JDK-8092345
It is indeed very strange that this method is missing but with the exception of you and me nobody seems to care. I have reported this issue more than 4 years ago and nothing has happened since then although the fix seems to be trivial. JDK-8092345
这篇关于JavaFX为什么AnimationTimer没有getStatus()或类似的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!