Hi-
I'm using a Swing Timer to run an animation in an applet. In every cycle a calculation is done and a figure drawn on a BufferedImage, and that image is drawn to my JPanel subclass via PaintComponent, via repaint(). The timing is sometimes extremeley ragged. I've measured elapsed time at various points in the cycle by printing out Date.getTime(), and my code takes 10 or 20 or 30 ms to run at each cycle (I don't know why such round numbers!). But when I have the timer set to 50 ms or less, the timer seems to often delay firing so that cycles will take 50-100 ms. The timer works perfectly when the delay is 100ms, but not dependably for delay <= 50ms, which I need. (I'm running AppletViewer under WinXP, 1.6GHz PentiumIV)
startRot() is called in response to a button push. As I said, updateimage() and paintComponent() usually finish withing 30ms of the timer firing. Any clues as to why the timer won't just fire every 50ms? Thanks.
JS
I'm using a Swing Timer to run an animation in an applet. In every cycle a calculation is done and a figure drawn on a BufferedImage, and that image is drawn to my JPanel subclass via PaintComponent, via repaint(). The timing is sometimes extremeley ragged. I've measured elapsed time at various points in the cycle by printing out Date.getTime(), and my code takes 10 or 20 or 30 ms to run at each cycle (I don't know why such round numbers!). But when I have the timer set to 50 ms or less, the timer seems to often delay firing so that cycles will take 50-100 ms. The timer works perfectly when the delay is 100ms, but not dependably for delay <= 50ms, which I need. (I'm running AppletViewer under WinXP, 1.6GHz PentiumIV)
startRot() is called in response to a button push. As I said, updateimage() and paintComponent() usually finish withing 30ms of the timer firing. Any clues as to why the timer won't just fire every 50ms? Thanks.
JS