Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Finding out when a component is "destroyed"

797060Aug 26 2010 — edited Aug 31 2010
I have a container (extends Container) that holds a few components, When one of these components (specifically a panel showing a video) is destroyed, or the whole container, I would like to call a JNI method disconnecting the camera.

Now, the container is in a JFrame, I could add a window listener to this to detect when the user closes the window, but in the future I will probably add this container to a different window, and in the interest of ease of use later on and encapsulation and all that I don't want to have to add a window listener with a destroy method to everything the container is placed in in the future - It should handel everything itself right?

So far I have tried a ContainerListener for a componentRemoved event, figuring it might remove the components when it gets cleaned up on close - but it doesn't get called. Can anyone help?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 28 2010
Added on Aug 26 2010
9 comments
857 views