I have a big problem I have a window that extends Jframe fenetere
contains two panels panel1 contains 2 buttons and panel2 is empty and I have two other panel extends JPanel panel3 panel4 and I like when I click button 1 i want to add 3 to the panel panel2 empty and when I click the button2 I want to add a panel4 panel2 and disappear the panel3 knowing that I work on netbeans:
You need to call revalidate() and repaint() on the parent when you add/remove a child.
If your intention is to display only one panel at one time, but switch panels, the check out CardLayout