Hello,
I have a JPanel with a GridBagLayout. And I would like to give the user the possibility to switch two components. I tried it like that, but it doesn't work, what is wrong?
public void switchSites( boolean b )
{
this.remove( blueSite );
this.remove( whiteSite );
GridBagConstraints c = new GridBagConstraints();
c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.BOTH;
c.gridheight = 3;
c.gridx = 0;
c.gridy = 0;
c.weightx = 1.0;
c.weighty = 1.0;
if( b )
{
this.add( whiteSite, c );
c.gridx = 2;
this.add( blueSite, c );
}
else
{
this.add( blueSite, c );
c.gridx = 2;
this.add( whiteSite, c );
}
this.repaint();
this.validate();
}