Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

remove and add to Panels

Status
Not open for further replies.

KevinWeav

Programmer
Dec 9, 2001
8
0
0
GB
In the code fragment below I want to remove a control and then add another to a panel. However, all that happens is that the original control first disappears with the second control not appearing. What am I doing wrong and/or how else can I solve this problem when I want to change controls in a panel? (This is a simplified version of my actual problem of switching panels in the center of a BorderLayout).

Code:

add(one, "Center");
...
switch(number) {
case 1:
changePanel.remove(two);
changePanel.add(one);
break;

case 2:
changePanel.remove(one);
changePanel.add(two);
break;
}
...
Many thanks in advance

Kevin
 
If you add
changePanel.updateUI();
in every case you should get the result you want
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top