Example usage for java.awt.event ContainerEvent COMPONENT_ADDED

List of usage examples for java.awt.event ContainerEvent COMPONENT_ADDED

Introduction

In this page you can find the example usage for java.awt.event ContainerEvent COMPONENT_ADDED.

Prototype

int COMPONENT_ADDED

To view the source code for java.awt.event ContainerEvent COMPONENT_ADDED.

Click Source Link

Document

This event indicates that a component was added to the container.

Usage

From source file:org.eclipse.jubula.rc.swing.listener.ComponentHandler.java

/**
 * {@inheritDoc}/* www  . j  av  a 2  s.co m*/
 */
public void eventDispatched(AWTEvent event) {

    final ClassLoader originalCL = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
    try {
        if (log.isDebugEnabled()) {
            log.debug(event.paramString());
        }
        final int id = event.getID();
        ComponentEvent componentEvent;
        switch (id) {
        case WindowEvent.WINDOW_ACTIVATED:
        case WindowEvent.WINDOW_OPENED:
            // add recursivly all components to AUTHierarchy 
            // and create names for unnamed components
            Window window = ((WindowEvent) event).getWindow();
            autHierarchy.add(window);
            break;
        case ContainerEvent.COMPONENT_ADDED:
            checkContainerListener((ContainerEvent) event);
            break;
        case ComponentEvent.COMPONENT_HIDDEN:
            componentEvent = (ComponentEvent) event;
            if (!hasListener(componentEvent.getComponent(), ComponentListener.class)) {
                autHierarchy.componentHidden(componentEvent);
            }
            break;
        case ComponentEvent.COMPONENT_SHOWN:
            componentEvent = (ComponentEvent) event;
            if (!hasListener(componentEvent.getComponent(), ComponentListener.class)) {
                autHierarchy.componentShown(componentEvent);
            }
            break;
        default:
            // do nothing
        }
        if (AUTServer.getInstance().getMode() == ChangeAUTModeMessage.OBJECT_MAPPING) {

            AUTServer.getInstance().updateHighLighter();
        }
    } catch (Throwable t) {
        log.error("exception during ComponentHandler", t); //$NON-NLS-1$
    } finally {
        Thread.currentThread().setContextClassLoader(originalCL);
    }
}