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
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