Placing a new JPanel over a paint overriden JPanel
Hi, I have a term project where I'm coding a 2D game with Java.
Now, I have the case as:
I have a JPanel which implements ActionListener and overrides paint method.
My JFrame starst with a Menu JPanel. I press the Play button, then Game JPanel takes the place and game starts, but after that, I press the ESC to go back to Menu JPanel. Problem starts here, when I create a new Menu JPanel, it doesn't appear at all. The JButtons over it doesn't appear until I hover over them. And background never changes.
I call the Menu JPanel like this:
This works, I know, because when I call another JPanel from the Menu JPanel (i.e. Help JPanel) it appears with this code:
Menu menu = new Menu();
I think the repaint(); method that I call in Game JPanel has a conflict with the paint method I override in Game JPanel. I'm not into using CardLayout, because at this rate it's hard to implement.
Help helpPanel = new Help();
Here, if you want to see what I mean: http://www.tanshaydar.com/resim/panel.jpg