I am working on a program in which there is a JPanel in the center (and surrounded by JPanels, but they aren't important to this question). I need to bring up additional JPanels inside the center JPanel, at certain times. I don't seem to be able to find any information on how to do this.
There's lots of info about the different JPanel layouts, and adding JPanels to frames. I've even seen lots of things written about JPanels nested in other Jpanels. However, I'm just looking for the simple syntax to even call a JPanel from within an already existing JPanel, and I don't seem to be able to find it anywhere.
When I set up the JPanels initially from the main Frame, I use something like this:
Container c = getContentPane();
MenuPanel new = new MenuPanel(); //or replace "MenuPanel" with whatever objected I've created that extendJPanel
c.add(new);
However, if I try to use the same syntax in a JPanel, it says "Incompatible type". I'm guessing because I don't need to get a new ContentPane, maybe? But, then how to I get the JPanel to show up?
A link to a tutorial, or anything that would help, would be great. I've been searching for tutorials, and there are lots out there about JPanels, but none of them (that I've found) actually deal with calling a new JPanel from within an already existing one.