Make an added JPanel visible inside a parent JPanel
How to make an added JPanel visible inside a parent JPanel ? I am using Netbeans for designing my UI. I have a MainFrame.java , which contains two panels; namely headerPanel and bodyPanel . In headerPanel I have put three buttons,let it be button1 , button2 and button3 . Also I have created three separate files extending JPanel , name it panel1 , panel2 and panel3 . Then I added all my three panels inside bodypanel in MainFrame.java in constructor. bodyPanel.add(panel1); bodyPanel.add(panel2); bodyPanel.add(panel3); I want that on clicking the respective buttons only respective panels should