Yes, perhaps this is how double buffering is achieved in many Java games. You need a GraphicsId GraphicsId () method that uses another Graphics2D object to draw. from my little game:
private Main(){ ... this.doubleBuffer = new BufferedImage(this.WIDTH, this.HEIGHT, BufferedImage.TYPE_INT_RGB); this.doubleBufferG2D = (Graphics2D) doubleBuffer.createGraphics(); ... }
Somewhere else:
g2d.drawImage(doubleBuffer, null , 0, 0);
Edit: heh I realized that this is not the case above ... lemme think about it.
Edit2: Itβs good that the above can still use the sample, but the sequence of steps for drawing from one Graphics2D to another should be as follows: 1. From the Graphics2D object to the Image / BufferedImage object using drawGraphics (). 2. From Image / BufferedImage above, extract its Graphics2D object using itscreateGraphics ().
source share