• Post Reply Bookmark Topic Watch Topic
  • New Topic

Listeners - How to callback the object it is listening to  RSS feed

 
Sravan Kumar Chitiprolu
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is there a way for a listener object (ex: myContainerListener) to know
when it is being registered as a listener to a container object (in this case myContainer.addContainerListener(myContainerListener)) and get the reference of the object it is being registered to (i.e myContainerListener
being able to call back methods on myContainer).

Specifically, I am trying to create a windowsMenu object which implements a
container listener and listens to a list of desktoppanes. When Frames are being added to the Desktop, the menu should update itself with menu items for each frame. The menu also shall have titleMenuItem and cascadeMenuItem,
which basically should loop through all the desktopPanes it is listening to (this is where I need to get the reference of all the objects which have registered the menu as their containerListener) and try to cascade/title each of the desktoppane.

I appreciate any answer and also appreciate any better solution for window
management.

Thanks
Sravan
 
Eric Snell
Greenhorn
Posts: 28
Java Mac MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about creating an interface your frames can call to populate the menu. You can implement the interface to correctly populate your menu. The interface implementation could be the menu itself, or better yet an object that contains the menu and is responsible for populating it. Your frames would only depend on the interface, which should be relatively simple.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!