Graphics, AWT, Swing I part
the components in the Frame. Is there a way to get a list of the listeners out of a
given component? I really don t want to have to track every single button I add to
every single Frame, and every single Listener I add to every single component. If I
have to keep track of all of that, it sort of defeats a lot of the advantages of a
well defined object oriented system.
Answer: I think you re slightly confused here. When another object registers as a
listener for a component within the frame, it s the component within the frame that is
holding a reference to the external object in its listeners list   not vice versa. 
Which means you don t really need to explicitly remove every listener that any other
object registered on components in the frame. 
What you need to worry about is however the listeners that the frame itself registered
with some other components that are still alive. If the frame gets disposed without
removing these, the objects that were being listened to will retain a reference to the
frame and this can cause the frame to stay around as long as these objects which
hold these references stay alive.
So look for all Listeners that your frame registered itself as on components external
to itself (should be fairly easy to see since you normally do it in your constructor) and
remove those before disposing off the frame.
  
Kala
(c)1999, 2000, 2001 JavaFAQ.nu. All rights reserved worldwide.
This document is free for distribution, you can send it to everybody who is interested in Java.
This document can not be changed, either in whole or in part
without the express written permission of the publisher.
All questions please 
mailto:info@javafaq.nu
file:///F|/a_jsite/350_tips/graphics I.htm (5 of 5) [2001 07 08 11:24:55]






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java web hosting

 

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved