BufferStrategy vs DIY Double Buffering in JFrame

前端 未结 2 1634
一向
一向 2020-12-04 01:22

Until now, I\'ve done double buffering by creating and Image, drawing what I wanted to that Image using its associated Graphics object then draw that Image to the screen usi

2条回答
  •  误落风尘
    2020-12-04 01:54

    I've always had good results using the default BufferStrategy by being careful to

    • Always construct GUI components on the EDT
    • Never draw from a thread except the EDT

    This excellent example must double buffer because it draws continually on the initial thread rather than the EDT. In contrast, this fairly busy example relies on nothing more than repaint() called in response to a Swing Timer. I rarely need an offscreen buffer except for a composite. Finally, this tutorial article offers more guidelines.

提交回复
热议问题