1.4.2, WinXP, Netbeans
Hi all,
I just came back to my old project after 3-4 months of lifting heavy objects for money. I think I may have forgotten how to program, so I apologize if this is a stupid question.
I am trying to create a Swing GUI where the ContentPane has a BorderLayout. The graphics and action occur in the center area, which has no child; I draw to the ContentPane directly. Options and user input are on a JTabbedPane in the South, and scoring and time limit are displayed on a JPanel in the North.
I want the graphics drawn right on the contentPane to wrap snugly around the three tabs on the TabbedPane (they are on top of it), as well as around the TP itself. I figure the best way to do this is, draw the graphics to my buffer, then paint the TP onto the buffer, then flip. This is my code: (imageBuffer is just a blank BufferedImage)
backBuffer = ((Graphics2D) imageBuffer.getGraphics());
gameMap.drawIsometricMap(backBuffer);
managementTabbedPane.paint(backBuffer);
getContentPane().drawImage(backBuffer, 0, 0, this);
What ends up happening is, the TP paints once where it belongs, in the South, (and the TP functions normally), then it repaints about at about (0, 4) for the remainder of the program execution. The graphics overlap the real TP (because it isn’t repainting where it should), and the empty shell of a TP paints perfectly over the graphics, in the wrong place.
Does anyone know why this is happening? Basically, it seems to me that the TP contains the wrong information about exactly where it belongs at any given time. I tried setting its location absolutely (with setLocation(x, y)), didn’t work. Perhaps I’m on the wrong track to acheive this effect in the first place? Any help is much appreciated. Thanks,
Bret
