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:
Keep note of last two lines, without which your change will not be visible (repaint() somehow doesnt work).