I have a problem when I click a button to change the content of right_pan(JPanel) nothing happens;
I have 3 JPanel:
pan_glob therein lies the other two:
right_pan and left_pan(are integrated into the main JFrame named “main” see screenshot),and another external JPanel named cree_client (contains text box).

I’d like when I click a button, the content of cree_client(JPanel) is loaded into right_pan(JPanel).
I tried this but it does not work :
private void jMenuItem23ActionPerformed(java.awt.event.ActionEvent evt) {
cree_client cc=new cree_client();
this.right_pan.removeAll();
this.right_pan.validate();
this.right_pan.add(cc);
this.right_pan.revalidate();
}
ANY helps ?
First rule of using any UI toolkit: don’t remove/add children to control visibility. It never works very well in almost any UI toolkit. It requires more work on the toolkit to properly handle it, and that goes double for Swing. Instead use either visibility, or I bet what you should use is a
CardLayout. A panel with aCardLayoutwill allow you to flip between several screens:If you don’t want to flip between two or more screens, then you can use
setVisible()to hide and show the different screens just as well.