0

I'm making a game as my project in school. I'm having a problem regarding double buffering, im trying to draw an image (drawImage(,,,,)) into the double buffered image, I can't seem to make it work help please =D

public void render() {
 
if(doubleBufferImage==null){							
    		doubleBufferImage = createImage(PANEL_WIDTH,PANEL_HEIGHT);	// Set Size	
    		if(doubleBufferImage == null) {							// checks the buffer again
				System.out.println("doubleBufferedImage is null");
				return;
			}
		else
			doubleBufferG = doubleBufferImage.getGraphics();
 		}
 		
    	doubleBufferG.setColor(Color.BLACK);
		doubleBufferG.fillRect (0, 0, PANEL_WIDTH, PANEL_HEIGHT);
		
// display FPS
		doubleBufferG.setColor(Color.RED);
		doubleBufferG.drawString("FPS:" + FPS , 1 , 10);

		//doubleBufferG.drawImage(image1,400,400,this);           // THIS WOULD NOT WORK
		
		
		
	}
2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by esy928
0

You still have to render that doubleBufferImage to your component graphics context in your paintComponent(Graphics) method.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.