我已經通過改變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