我已经通过改变JScrollPane
的水平滚动条的值来制作动画,就像android操作系统的屏幕之间的转换。在跑步的第一秒钟(最多10秒)内,如果我要求动画,它不光滑并跳跃;但过了一段时间,我玩了(请求动画),它完全平滑。为什么会发生,更重要的是如何解决这个问题?为什么我的动画在第一次播放时不顺畅?
我不是说我的动画的第一秒不光滑,我的意思是,当我第一次开始我的程序时,我要求的动画不光滑,但后来在下一次,这是光滑的。
final JScrollBar br = mainContainerScrollPane.getHorizontalScrollBar();
ActionListener toTheRight = new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
if (br.getValue() + 140 <= destinationScreenValue)
{
br.setValue(br.getValue() + 140);
} else
{
br.setValue(destinationScreenValue);
currentScreenName = destinationScreenName;
timer.stop();
}
}
};
timer = new Timer(10, toTheRight);
timer.setRepeats(true);
timer.setCoalesce(true);
timer.start();
请向我们显示您的代码。 – 2013-02-10 19:53:32
没有任何代码示例告诉我们你在做什么,我们会浪费对方时间猜测什么可能是错误的 – MadProgrammer 2013-02-10 19:57:42
对不起,我写了我的代码,请注意大写 – Soheil 2013-02-10 20:15:15