Hi,
I’m trying to get informed about attach and detach events for arbitrary components. I looked at the api and the corresponding junit ComponentAttachDetachListenerTest but noticed that the listeners will be triggered for the container ( or even a layout of a container ) and not the individual component…
Any way to get a callback for this kind of event? In Swing this was simply done via a HierarchyListener…something like
public void startupController(JComponent component , final Controller controller) {
if (controller.getActivationMode() == ActivationMode.ON_SHOW) {
component.addAncestorListener(new AncestorListener() {
public void ancestorAdded(AncestorEvent event) {
activateController(controller);
}
public void ancestorRemoved(AncestorEvent event) {
deactivateController(controller);
}
public void ancestorMoved(AncestorEvent event) {
}
});
else if (controller.getActivationMode() == ActivationMode.ON_ADD) {
component.addHierarchyListener( new HierarchyListener() {
public void hierarchyChanged(HierarchyEvent event) {
if ((event.getChangeFlags() & HierarchyEvent.PARENT_CHANGED) != 0) {
if (component.getParent() != null)
activateController(controller);
else
deactivateController(controller);
}
}
});
} // else
Thanx