views:

630

answers:

1

I am currently working on an intro screen for a game designed using JOGL. I want the intro to be a JPanel with a few buttons to alter options before starting the game.

So, I have JFrame which I add a GLCanvas to. The GLCanvas also contains a GLEventListener. Finally, I add the JPanel.

I have overridden the JPanel paintComponent method to set a background image. I have a few buttons within the panel. Whenever you click the 'play' button, it calls a function which does:

frame.remove(JPanel); frame.repaint(); animator.start();

What happens is that my JPanel goes away correctly, but when repaint is called, my frame is just filled with grey. I know that the animator is starting correctly as the display method in my GLEventListener is getting called.

Does anyone know what the problem is there?

+2  A: 

What is your LayoutManager? If you didn't specify one, then by adding the JPanel you replace the GLCanvas.

I would make your code do this:
frame.remove(JPanel); frame.add(glcanvas); animator.start();
you may need to throw in a frame.revalidate(). I'm not up on how all that works right now.

KitsuneYMG