BufferStrategy vs DIY Double Buffering in JFrame

前端 未结 2 1637
一向
一向 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:50

    I recommend reading Painting in AWT and Swing if you haven't.

    I don't think you usually need Do-It-Yourself double buffering if you're using JFrame. Swing has built in double buffering which is turned on by default. Manually doing this yourself will just slow things down. You can check if double buffering is on by calling isDoubleBufferingEnabled() on any of your JComponents.

    There are cases where you may want to do this yourself, but that should be the exception rather than the rule. Maybe you're doing something involved like writing a game, in which case maybe my advice doesn't apply. Anyway, hopefully the above is useful info.

提交回复
热议问题