Hello Everybody Lets see if I can summarize the situation in few lines. I have a JFrame with BorderLayout, In the SOUTH part of the FRAME I have a Panel with 4 buttons, I want to change the layout of CENTER Panel based on the button pressed in the SOUTH section. e.g. I might want to change the centerPanel from BorderLayout to GridLayout or something like that. I tried to do that but it is not working. I am posting the code below that I used. Please help me it is driving me nuts, not understanding why the code is behaving like it is. Thanks
Results: 1. On initial screen if I press Next Button it works like it is suppose to. 2. If I press Previous button the centerPanel becomes blank. WHY?? 3. If I press the next button after pressing previous button the centerPanel remains blank. WHY??? 4. If I press prev, next, next then the second next makes the centerPanel like it is suppose to. Help PLEASE!!! Vinay
Hi Vinay, You are very close. Instead of removing and adding the center component use the invalidate/validate methods of the Container. I have altered your code to work and I am showing it to you below. The commented lines are not required and the bold ones are added to make it work.
Joined: Nov 07, 2001
Hi Manfred THANKS A LOT!!!. I was going crazy. Vinay
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Changing Layout of a Panel in Border Layout