Search code examples
javaswingdrawbufferedimagegraphics2d

Is it better to draw on BufferedImage and put it in the panel or draw on the panel itself?


I wanted to draw a basic stroke which then can be reflected and rotate. But I don't know whether to draw the stroke on BufferedImage and then place it on a Jpanel or draw the stroke on the Jpanel itself? Which way is better?


Solution

  • I wanted to draw a basic stroke which then can be reflected and rotate

    If you are dynamically changing the painting then just do it on the panel.

    If you are doing static painting that doesn't change then you could use a BufferedImage.

    But Swing is double buffered by default so it won't make a big difference either way.