0
我写了一个执行一些长时间运行任务的小应用程序。我不想让用户等待并看到进度条,而是想显示一些(更改)关于应用程序的信息。JavaFX:暂停转换,不等于时间
为此,我写扩展Pane
的构造内的以下代码:
FadeTransition fadeOutTransition = new FadeTransition(Duration.millis(1000), this);
fadeOutTransition.setFromValue(0.8);
fadeOutTransition.setToValue(0.0);
同样的fadeInTransition
。并进一步...
SequentialTransition seqTransition = new SequentialTransition (
new Transition() {
{ setInterpolator(Interpolator.DISCRETE);
setCycleDuration(Duration.seconds(1)); }
protected void interpolate(double frac) {
int nextElement = (int) ((explenations.size() - 1) * Math.random());
Explenation explenation = explenations.get(nextElement);
questionLabel.setText(explenation.getQuestion());
answerLabel.setText(explenation.getAnswer());
}
},
fadeInTransition,
new PauseTransition(Duration.seconds(15)),
fadeOutTransition
);
我woud喜欢的是淡入,在那里停留约15秒,然后再次淡出的文本。不幸的是,动画闪烁,移动得越来越快 - 而且PauseTransition
从不需要15秒!代码有什么问题?我使用的Java 7,和JavaFX 2.2在Mac OS X