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
		
		
		
	}

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

oh.. I see, thanks man =D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.