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();