Transparency and the Graphics2D object

Hi all at Java-Gaming!

I am very new here. I am actually quite new to Java as well. I apologize if this topic’s solution exists elsewhere, but I wasn’t entirely sure what I should search.

I am having a problem with Status bars in a little experimental game I am creating. The problem lies in the fact that when you draw a transparent image with a Graphics2D object, the transparent part of the image overwrites any previously drawn rectangles/circles etc. As an example;

http://puu.sh/6Y7ok.png

Rather, the bars should be filled with red and blue respectively. The other aspect I feel confident that I will be able to program, but this part has been bugging me for a while. My current code to resulting in the above is;

	public void draw(Graphics2D g, Color c) {
		
		g.setColor(c); //setting the back color
		g.drawRect(x, y, this.width, this.height); //drawing the backcolor
		
		g.drawImage(image, x, y, null); //overlaying the transparent gif image (BufferedImage image = ImageIO.read(getClass().getResourceAsStream("path");)
		
	}

Any insight, even an alternative way to deal with drawing the Status bars, would be greatly appreciated! :wink: