参考
https://gist.github.com/jewelsea/2658491
这是我的导致错误的代码块(标有*)
Calendar time = GregorianCalendar.getInstance();
double second = time.get(Calendar.SECOND);
double minute = time.get(Calendar.MINUTE);
double hour = time.get(Calendar.HOUR);
double secondStartPos = 6*second;
double minuteStartPos = 6*minute;
double hourStartPos = 30*hour + (0.5*minuteStartPos);
//Define rotations
Rotate secondRotate = new Rotate(secondStartPos, 150, 150);
Rotate minuteRotate = new Rotate(minuteStartPos, 150, 150);
Rotate hourRotate = new Rotate( hourStartPos, 150, 150);
secondHand.getTransforms().add(secondRotate);
minuteHand.getTransforms().add(minuteRotate);
hourHand.getTransforms().add(hourRotate);
//Time line for second
Timeline secondTime = new Timeline(
* new KeyFrame(
Duration.seconds(60),
** new KeyValue(
secondRotate.angleProperty(),
360 + secondStartPos ,
Interpolator.LINEAR
)
)
);
错误是
*构造函数 KeyFrame(Duration, KeyValue) 未定义
**构造函数 KeyValue(DoubleProperty, double, Interpolator) 未定义
我查看了 API 文档
docs.oracle.com/javafx/2/api/javafx/animation/KeyValue.html
http://docs.oracle.com/javafx/2/api/javafx/animation/KeyFrame.html
但无法弄清楚错误是什么。有人可以帮忙吗?