Results 1 to 14 of 14
  1. #1
    Tawi is offline Senior Member
    Join Date
    Feb 2013
    Posts
    118
    Rep Power
    0

    Default Can frame A and frame B add this component C simultaneously?

    Quote Originally Posted by Norm View Post
    Please explain what you mean.

    I have two frames which are Frame A and Frame B and a component C. Can frame A and frame B add this component C simultaneously?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: Can frame A and frame B add this component C simultaneously?

    New topic moved to own thread.

    No,a component can only have one parent.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default Re: Can frame A and frame B add this component C simultaneously?

    If you had read the API documentation for the Container class (to which you add your Component):

    If the component is not an ancestor of this container and has a non-null parent, it is removed from its current parent before it is added to this container.
    ... you wouldn't have had the need to ask this question. It is answered now (Norm already did, see above), so we can consider this thread closed.

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,367
    Rep Power
    6

    Default Re: Can frame A and frame B add this component C simultaneously?

    You can see the proof of that statement in the fact that Component has a getParent() method:

    Component (Java Platform SE 7 )

    Only one parent.

    Swing works with models; you can create one model and share those among several components so that if you update the state of one, you update the state of all of them.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    Tawi is offline Senior Member
    Join Date
    Feb 2013
    Posts
    118
    Rep Power
    0

    Default Re: Can frame A and frame B add this component C simultaneously?

    So what shall I do to make a short code to clone this C component? I mean I do not want to retype all of the code, can I use copy paste to create the clone of C?

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default Re: Can frame A and frame B add this component C simultaneously?

    Do you know what a 'book' is? You should read one with the word 'Java' on the cover.

    Jos

    ps. reading doesn't make your eyeballs hurt, nor does it make them bleed.
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    Tawi is offline Senior Member
    Join Date
    Feb 2013
    Posts
    118
    Rep Power
    0

    Default Re: Can frame A and frame B add this component C simultaneously?

    Yes but I do not have enough time to read, so please tell me ok?

  8. #8
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,094
    Rep Power
    4

    Default Re: Can frame A and frame B add this component C simultaneously?

    Quote Originally Posted by Tawi View Post
    Yes but I do not have enough time to read, so please tell me ok?
    I have the feeling somebody is going to pop out of my screen and shout "Smile!!! You're on Candid Web Camera!!!"... This can't be real.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  9. #9
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,367
    Rep Power
    6

    Default Re: Can frame A and frame B add this component C simultaneously?

    Quote Originally Posted by Tawi View Post
    Yes but I do not have enough time to read, so please tell me ok?
    Who are you kidding? You have plenty of time to waste asking countless questions in this forum, you most definitely have time to read. You just don't have the patience. Alas, you like anyone else are not going to do this by cutting corners.

    Quote Originally Posted by SurfMan View Post
    I have the feeling somebody is going to pop out of my screen and shout "Smile!!! You're on Candid Web Camera!!!"... This can't be real.
    You're the second person in two weeks to make that reference :p
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  10. #10
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default Re: Can frame A and frame B add this component C simultaneously?

    I banned the critter for a week; that should give him/her some time to read instead of asking silly questions.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  11. #11
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,367
    Rep Power
    6

    Default Re: Can frame A and frame B add this component C simultaneously?

    LOL! Jos, you are my hero.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  12. #12
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,094
    Rep Power
    4

    Default Re: Can frame A and frame B add this component C simultaneously?

    ^^ /me sends a case of Grolsch to Jos!
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  13. #13
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,367
    Rep Power
    6

    Default Re: Can frame A and frame B add this component C simultaneously?

    Quote Originally Posted by SurfMan View Post
    ^^ /me sends a case of Grolsch to Jos!
    Give me the guy's address so I can stand eerily across the street every Saturday.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  14. #14
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,033
    Rep Power
    6

    Default Re: Can frame A and frame B add this component C simultaneously?

    Finally!!
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Replies: 7
    Last Post: 04-01-2012, 05:11 AM
  2. Need help with Image Component Frame
    By Urasb in forum AWT / Swing
    Replies: 2
    Last Post: 02-19-2011, 05:54 PM
  3. Replies: 4
    Last Post: 01-18-2011, 09:22 AM
  4. Java slave Frame access to its owner main frame problem
    By cagdaseckin in forum New To Java
    Replies: 0
    Last Post: 12-10-2010, 11:40 AM
  5. Replies: 7
    Last Post: 11-02-2009, 07:31 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
  •