Delete a panel inside a panel (2)

H

HS1

Hello

After got a help, I can delete a sub-panel inside a main-panel (a container
with VerticalFlowLayout) for a delete button ( the button inside a
sub-panel) by using:

JPanel mainPanel = (JPanel)this.getParent();
mainPanel.remove(this); // "this" is the sub-panel
mainPanel.repaint();

However, when I use this code, the sub panel is deleted but the main panel
did not change. For example I have three sub-panels (top, centre, bottom).
When I delete the centre sub-panel, this sub-panel is deleted but the top
and bottom still in the same place. What I want is that the bottom sub-panel
will move up. Do I have to remove all sub-panels then add them again or
there is a better way to do that???

Could you please help
Thank you
SH1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top