List of usage examples for java.awt Container getContainerListeners
public synchronized ContainerListener[] getContainerListeners()
From source file:Main.java
/** * Destroys container by destroying its childs structure and removing all * listeners./*w w w . j av a2 s .co m*/ * * @param container * container to destroy */ public static void destroyContainer(final Container container) { for (final Container toDestroy : collectAllContainers(container)) { toDestroy.removeAll(); toDestroy.setLayout(null); for (final MouseListener listener : toDestroy.getMouseListeners()) { toDestroy.removeMouseListener(listener); } for (final MouseMotionListener listener : toDestroy.getMouseMotionListeners()) { toDestroy.removeMouseMotionListener(listener); } for (final MouseWheelListener listener : toDestroy.getMouseWheelListeners()) { toDestroy.removeMouseWheelListener(listener); } for (final KeyListener listener : toDestroy.getKeyListeners()) { toDestroy.removeKeyListener(listener); } for (final ComponentListener listener : toDestroy.getComponentListeners()) { toDestroy.removeComponentListener(listener); } for (final ContainerListener listener : toDestroy.getContainerListeners()) { toDestroy.removeContainerListener(listener); } if (toDestroy instanceof JComponent) { final JComponent jComponent = (JComponent) toDestroy; for (final AncestorListener listener : jComponent.getAncestorListeners()) { jComponent.removeAncestorListener(listener); } } } }
From source file:org.eclipse.jubula.rc.swing.components.AUTSwingHierarchy.java
/** * Register the AutHierarchy as a container listener to <code>container</code>. * @param container the container to register to *///from www.jav a 2s. c o m private void registerAsContainerListener(final Container container) { Runnable registrationRunnable = new Runnable() { public void run() { if (log.isInfoEnabled()) { log.info("registering as listener to container " + container); //$NON-NLS-1$ } ContainerListener[] listener = container.getContainerListeners(); for (int i = 0; i < listener.length; i++) { if (listener[i] instanceof AUTSwingHierarchy) { return; } } container.addContainerListener(AUTSwingHierarchy.this); } }; registerListener(registrationRunnable); }