File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Member object talks back to parent object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic

Member object talks back to parent object

Dave Elwood
Ranch Hand

Joined: Dec 27, 2002
Posts: 84
I am in a situation where I have two classes AA and BB,
where "BB bb;" is a member of AA aa.

I wish to send info from the interior of class BB up to class AA.

Note the direction - from AA to BB is easy, since bb is a member of aa, but talking back to aa??

Using events? All literature I find about events deals with Keyboard events, Timer events, Mouse events, all induced by external actions. Nothing about my own custom-made 'burp' events, induced by the code in the BB object.

Is there a method other than using events for a member object to communication with its parent object?
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11955

your terminology is confusing. 'parent' usually refers to an inheritance relationship:

Member object usually refers to a class being a member variable of another class:

In the second case, it would be very dangerous to expect to be able to do this. How do you know if the member variable is actually in a container class? What if it is in two or more? What if it is one minute, but not the next?

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Dave Elwood
Ranch Hand

Joined: Dec 27, 2002
Posts: 84
Yes, my terminology is really for the birds, but whence the worry about membership in a container class??
It doesn't really seem realistic to me.

(And I solved the custom event problem in the meantime)

Anyway this is the scenario.

1. BB bb is a member of AA aa

2. and AA aa is a member of main()

3. In the future AA will be a form with text boxes and a panel and
the class BB will be the code behind the panel (so BB is a member of AA).
I want a change in the panel code to fill in a text box in the AA form when circumstances demand it

This is main()

This is AA

This is BB

These are BurpEvent, BurpListener and MyBurpListener from three files

all the nifty event code is from
Dave Elwood
Ranch Hand

Joined: Dec 27, 2002
Posts: 84
found the solution, detailed in
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46337
But why did you start a new thread. Closing thread.
I agree. Here's the link:
subject: Member object talks back to parent object
It's not a secret anymore!