Results 1 to 4 of 4
  1. #1
    itaipee is offline Member
    Join Date
    Dec 2008
    Posts
    99
    Rep Power
    0

    Default how to remove component from panel

    the title is
    When I remove the component from the panel ( jPanel.remove(jButton1); )
    then the component is disable - but still apear on the panel. I cant use it but it is still there.
    How I remove the component from the panel - from the visible part ?

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    843
    Rep Power
    6

    Default

    use jButton1.setVisible(false) and check

  3. #3
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    7

    Default

    if you remove component, you need to call container.revalidate()

    after remove() method call, the component is removed, but the layout not yet updated

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    and also it requires a call to container.repaint() as well.

Similar Threads

  1. panel resizing
    By kumar_gemi in forum New To Java
    Replies: 3
    Last Post: 03-13-2009, 03:51 AM
  2. i want to remove JScrollPane from panel
    By ravrajesh.ap in forum AWT / Swing
    Replies: 1
    Last Post: 01-03-2009, 05:49 PM
  3. panel positioning
    By shwein in forum New To Java
    Replies: 4
    Last Post: 09-09-2008, 06:15 PM
  4. add image on panel
    By samiksha.goel in forum AWT / Swing
    Replies: 4
    Last Post: 08-02-2008, 08:38 PM
  5. how to remove all component in container(Jpanel)
    By SaYuNaRa in forum New To Java
    Replies: 3
    Last Post: 04-17-2008, 05:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •