If I am correct, you need to create a parent JPanel and create another JPanel
in it. Then you can keep replacing this JPanel. Here is the sample code:
Code:
parentJPanel.removeAll();
parentJPanel.add(newJPanel);
parentJPanel.setVisible(false);
parentJPanel.setVisible(true);
Keep note of last two lines, without which your change will not be visible (repaint() somehow doesnt work).