FileDocCategorySizeDatePackage
ComponentMap.javaAPI DocExample753Mon Jan 09 11:02:02 GMT 2006None

ComponentMap.java

import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.awt.event.*;

public class ComponentMap extends HashMap implements AWTEventListener {
    
    public ComponentMap() {
        Toolkit tk = Toolkit.getDefaultToolkit();
        tk.addAWTEventListener(this,
            AWTEvent.COMPONENT_EVENT_MASK);
    }

    public void eventDispatched(AWTEvent evt) {
        try {
            // p("evt = " + evt);
            ComponentEvent ce = (ComponentEvent)evt;
            // p("storing component: " + ce.getComponent().getName());
            this.put(
                ce.getComponent().getName(),
                ce.getComponent()
                );
        } catch (Exception ex) {
            // p("ex: " + ex);
        }
    }

}