Results 1 to 3 of 3
  1. #1
    Chillout is offline Member
    Join Date
    Apr 2012
    Posts
    1
    Rep Power
    0

    Unhappy Container - getParent

    Hi.
    First of all sorry for my english but i hope u can understand me!
    i have a frame with 3 JPanels and 2 JButtons, the first panel have the other 2 panels and each of theese 2 panel has 1 button.
    i made my own Actionlistener in another class.
    What i want is if i click on a button i want the other button to be removed...( i know it would be so easy if i just use 1 class but i dont want this way)
    I use getParent method to reach the frame so i can get the other panel wich have the button i want to remove.
    How do i know how many times i can use getParent method?(if i dont know how many container exists above that button).
    And another strange thing for me, i have just those 2 panels above my button but i can use getParent() 5 times and there are 3 more container why?:
    class javax.swing.JPanel /i made it
    class javax.swing.JPanel /i made it
    class javax.swing.JLayeredPane /dunno what it is
    class javax.swing.JRootPane /dunno what it is
    class graphical.Surface /i guess its the frame
    thx for ur help

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default Re: Container - getParent

    You are looking at how the java classes work internally. Some of the API will describe that. Also you could read the source for the classes you are using t see what they do.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: Container - getParent

    Quote Originally Posted by Chillout View Post
    I use getParent method to reach the frame so i can get the other panel wich have the button i want to remove.
    How do i know how many times i can use getParent method?(if i dont know how many container exists above that button).
    Read through the SwingUtilities API. You'll find a useful method there.

    Quote Originally Posted by Chillout View Post
    And another strange thing for me, i have just those 2 panels above my button but i can use getParent() 5 times and there are 3 more container why?:
    class javax.swing.JPanel /i made it
    class javax.swing.JPanel /i made it
    class javax.swing.JLayeredPane /dunno what it is
    class javax.swing.JRootPane /dunno what it is
    class graphical.Surface /i guess its the frame
    thx for ur help
    Read the API for JRootPane.

    Moving to the AWT/Swing forum.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. j2me container app
    By AfricanEinstein in forum CLDC and MIDP
    Replies: 0
    Last Post: 01-21-2011, 08:02 PM
  2. Help with adding a Container within a Container
    By JoKeR313 in forum New To Java
    Replies: 4
    Last Post: 01-02-2011, 04:59 AM
  3. Applet as container .
    By pawankumarom in forum Java Applets
    Replies: 5
    Last Post: 04-23-2009, 06:17 AM
  4. Replies: 3
    Last Post: 04-21-2009, 11:01 PM

Posting Permissions

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