Rectangle rendering issues

I am rendering rectangles using this code:

for(int r = 0; r < map.height; r++) {
	for(int c = 0; c < map.width; c++) {
		if(!map.getTile(c, r).passable) {
			gr.fillRect(
				(int)(c * GameComponent.tileSize),
				(int)(r * GameComponent.tileSize),
				GameComponent.tileSize,
				GameComponent.tileSize
			);
		} else {
			gr.drawRect(
				(int)(c * GameComponent.tileSize),
				(int)(r * GameComponent.tileSize),
				GameComponent.tileSize,
				GameComponent.tileSize
			);
		}
	}
}

For some reason, the edges of the outer filled rectangles render slightly off.

https://dl.dropbox.com/u/41733151/frame.png

I cannot figure out why?

Thanks,
novasharp

If i remember it correct, drawrect draws the lines at the center of the borders, so if your lines are 2 pixels, they are always 1 pixel bigger.
Try this:


         gr.drawRect(
            (int)(c * GameComponent.tileSize + 1),
            (int)(r * GameComponent.tileSize + 1),
            GameComponent.tileSize - 1,
            GameComponent.tileSize - 1
         );

Where 1 is your line width /2

Thanks, that fixed it.