Putting one JPanel on top of another, can't get rid of gap at top
I am making a simple program for fun, where I want to have one panel, the back panel, with a mouse listener on it, and one panel in front of it, the front panel, that will display an image.
The end goal is to have the user be able to click on the panel, the applet will process the information and give the point to the front panel, which will then draw the point, on it's own graphics object in paintComponent. Therefore it is very important that the two panels coincide perfectly, so the the point drawn is at the same location as the one passed in.
Unfortunately I have a gap between my two panels, at the top, about 5 pixels or so. In the picture below, the back panel is drawing a red rectangle over it's entire area, and the front panel is displaying the picture. My x points work fine, as they both line up. However when the front panel draws the point, it is lower than where the mouse click occurs, because of this misalignment.
Does anyone have any idea where this is coming from, or how to remedy? Thanks in advance.
Picture explanation - The back panel and front panel are both contained inside another panel, represented by the blue rectange. The front panel was simply added to the back panel, which was added to the other 'subpanel' which has another panel down at the bottom, and it's setup in a box layout y-axis.