Java animation stutters when not moving mouse cursor

后端 未结 4 2046
难免孤独
难免孤独 2020-12-05 05:06

I have a quite simple animation, a text in a big font moving continuously (pixel by pixel) to the left. The text is first converted to an image, then a timer task is started

4条回答
  •  不知归路
    2020-12-05 05:53

    Try calling this method when you are done drawing:

     Toolkit.getDefaultToolkit().sync();
    

    This flushs the graphics buffer which some systems like Linux use. See the Javadoc: http://docs.oracle.com/javase/7/docs/api/java/awt/Toolkit.html#sync()

提交回复
热议问题