How do you double buffer in java for a game?

后端 未结 4 1033
逝去的感伤
逝去的感伤 2020-11-27 07:35

So in the game I\'m working on, I have a marble follow the mouse, but when it does this the screen flickers.

The background includes two jpegs and 9 rectangles. How

4条回答
  •  一生所求
    2020-11-27 07:55

    Swing supports double buffering automatically, so you don't need to code anything.

    Just call setDoubleBuffered(true) on your top-level component (typically a JPanel) and it should all work.

    See: setDoubleBuffered

提交回复
热议问题