Results 1 to 2 of 2
- 02-13-2011, 07:58 AM #1
Member
- Join Date
- Sep 2010
- Posts
- 30
- Rep Power
- 0
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.
- 02-13-2011, 06:25 PM #2
Member
- Join Date
- Sep 2010
- Posts
- 30
- Rep Power
- 0
Similar Threads
-
Putting graphics into the run() method.
By theCardboardBox in forum New To JavaReplies: 11Last Post: 11-17-2010, 06:33 PM -
Putting Applet on web with images
By Peetahzee in forum New To JavaReplies: 1Last Post: 04-18-2010, 08:35 PM -
Putting a graph on another JPanel in another JFrame
By thestarncy in forum AWT / SwingReplies: 10Last Post: 12-31-2009, 04:45 PM -
Putting code together.
By newbee in forum New To JavaReplies: 3Last Post: 04-17-2008, 03:53 AM -
Putting your own type in a Set
By Java Tip in forum java.langReplies: 0Last Post: 04-15-2008, 07:32 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks