I've created new JPanel from Swing GUI form called myNewPanel and I have one button in my JFrame it called btnClickMe when the button is clicked I want the panel in the Jframe to be removed and replaced by myNewPanel

I've tried my code but it not working for me nothing change

    oldPanel.remove(pnlMenuReplace);
            originalPanel = new myNewPanel();
            oldPanel.add(originalPanel);
            oldPanel.validate();
            oldPanel.repaint();

it's a bit little code to be definitive.
what you also can do, is add them both, just toggle between visible and invisible.