Delete a panel inside a panel (2)

Discussion in 'Java' started by HS1, Dec 7, 2004.

  1. HS1

    HS1 Guest

    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
    HS1, Dec 7, 2004
    #1
    1. Advertising

  2. On Wed, 8 Dec 2004 08:49:16 +1300, HS1 wrote:

    > What I want is that the bottom sub-panel
    > will move up.


    Probably validate()/pack(). For more specific answers,
    we'd need more specific code.
    <http://www.physci.org/codes/sscce.jsp>

    BTW - best group for GUI questions..
    <http://www.physci.org/codes/sscce.jsp>

    --
    Andrew Thompson
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.PhySci.org/ Open-source software suite
    http://www.1point1C.org/ Science & Technology
    http://www.LensEscapes.com/ Images that escape the mundane
    Andrew Thompson, Dec 7, 2004
    #2
    1. Advertising

  3. On Tue, 07 Dec 2004 21:41:19 GMT, Andrew Thompson wrote:

    > BTW - best group for GUI questions..
    > <http://www.physci.org/codes/sscce.jsp>


    ...ahem. Rather <http://www.physci.org/codes/javafaq.jsp#cljg>
    Andrew Thompson, Dec 7, 2004
    #3
  4. HS1

    HS1 Guest

    Thanks
    I use validate and it works
    Thank you for the link

    "Andrew Thompson" <> wrote in message
    news:ltukreefh3j1$.wfgmmirgsbhb$...
    > On Tue, 07 Dec 2004 21:41:19 GMT, Andrew Thompson wrote:
    >
    > > BTW - best group for GUI questions..
    > > <http://www.physci.org/codes/sscce.jsp>

    >
    > ..ahem. Rather <http://www.physci.org/codes/javafaq.jsp#cljg>
    HS1, Dec 7, 2004
    #4
  5. HS1 wrote:
    >
    > I use validate and it works
    > Thank you for the link
    >


    Better to use revalidate() instead of validate() for Swing components.

    BK
    Babu Kalakrishnan, Dec 8, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Harry
    Replies:
    3
    Views:
    531
    Harry Singh
    Nov 10, 2003
  2. HS1
    Replies:
    3
    Views:
    476
  3. JC
    Replies:
    1
    Views:
    737
    Michael Rauscher
    Aug 9, 2006
  4. Ulf Meinhardt
    Replies:
    0
    Views:
    600
    Ulf Meinhardt
    Jul 7, 2009
  5. Robin Wenger
    Replies:
    0
    Views:
    2,906
    Robin Wenger
    Aug 18, 2011
Loading...

Share This Page