Java Code Examples for java.awt.Container#addContainerListener()

The following examples show how to use java.awt.Container#addContainerListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileOpenDropHandler.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void initializeComponents(Component comp) {
	if (comp instanceof CellRendererPane) {
		return;
	}

	if (comp instanceof Container) {
		Container c = (Container) comp;
		c.addContainerListener(this);
		Component comps[] = c.getComponents();
		for (Component element : comps) {
			initializeComponents(element);
		}
	}
	DropTarget primaryDropTarget = comp.getDropTarget();
	if (primaryDropTarget != null) {
		new CascadedDropTarget(comp, primaryDropTarget, globalDropTarget);
	}
}
 
Example 2
Source File: HyperlinkSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void registerChildren(Component c, IssueLinker issueLinker) {
    if(c instanceof Container) {
        Container container = (Container) c;
        container.removeContainerListener(regListener);
        container.addContainerListener(regListener);
        
        Component[] components = container.getComponents();
        for (Component cmp : components) {
            registerChildren(cmp, issueLinker);
        }
    } if(c instanceof JTextPane) {
        JTextPane tp = (JTextPane) c;
        if(!tp.isEditable()) {
            registerTask.add(tp, issueLinker);
        }
    }
}
 
Example 3
Source File: ReplaceDialog.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
private void registerKeyAction(Component c) {
    if (c instanceof ReplaceDialog == false) {
        c.removeKeyListener(this);
        c.addKeyListener(this);
    }

    if (c instanceof Container) {
        Container cnt = (Container) c;
        cnt.removeContainerListener(this);
        cnt.addContainerListener(this);
        Component[] ch = cnt.getComponents();
        for (int i = 0; i < ch.length; i++) {
            registerKeyAction(ch[i]);
        }
    }
}
 
Example 4
Source File: EscapableDialog.java    From rest-client with Apache License 2.0 6 votes vote down vote up
private void registerKeyAction(Component c) {
    if (c instanceof EscapableDialog == false) {
        c.removeKeyListener(this);
        c.addKeyListener(this);
    }

    if (c instanceof Container) {
        Container cnt = (Container) c;
        cnt.removeContainerListener(this);
        cnt.addContainerListener(this);
        Component[] ch = cnt.getComponents();
        for (int i = 0; i < ch.length; i++) {
            registerKeyAction(ch[i]);
        }
    }
}
 
Example 5
Source File: DescendantListener.java    From pumpernickel with MIT License 5 votes vote down vote up
private void processAddition(Component c) {
	if (components.add(c)) {
		register(c);
		if (c instanceof Container) {
			Container container = (Container) c;
			container.addContainerListener(containerListener);
			for (Component child : container.getComponents()) {
				processAddition(child);
			}
		}
	}
}
 
Example 6
Source File: MagnificationPanel.java    From pumpernickel with MIT License 5 votes vote down vote up
/**
 * Add MouseListeners to a component and its children. If children have a
 * MouseListener for mouse-moved events, then this component won't otherwise
 * receive mouse-moved events (and therefore it won't repaint correctly).
 * <p>
 * A common instance of this problem is simply the presence of tooltips
 * (which require a MouseListener).
 */
private void addMouseListeners(Component c) {
	c.addMouseMotionListener(mouseListener);
	c.addMouseListener(mouseListener);
	if (c instanceof Container) {
		Container c2 = (Container) c;
		c2.addContainerListener(containerListener);
		for (Component child : c2.getComponents()) {
			addMouseListeners(child);
		}
	}
}
 
Example 7
Source File: KeyInputManager.java    From ontopia with Apache License 2.0 5 votes vote down vote up
private void listenTo(Component component) {
  component.addKeyListener(this);
  if (component instanceof Container) {
    Container container = (Container)component;
    container.addContainerListener(this);
    
    Component components[] = container.getComponents();
    for (int i = 0; i < components.length; i++) {
      Component currentComponent = components[i];
      listenTo(currentComponent);
    }
  }
}
 
Example 8
Source File: HighlightNode.java    From ontopia with Apache License 2.0 5 votes vote down vote up
private void listenTo(Component component) {
  component.addKeyListener(this);
  if (component instanceof Container) {
    Container container = (Container)component;
    container.addContainerListener(this);
    
    Component components[] = container.getComponents();
    for (int i = 0; i < components.length; i++) {
      Component currentComponent = components[i];
      listenTo(currentComponent);
    }
  }
}
 
Example 9
Source File: ClarifyingKeyListener.java    From SNT with GNU General Public License v3.0 5 votes vote down vote up
public void addKeyAndContainerListenerRecursively(final Component c) {
	c.addKeyListener(this);
	if (c instanceof Container) {
		final Container container = (Container) c;
		container.addContainerListener(this);
		final Component[] children = container.getComponents();
		for (int i = 0; i < children.length; i++) {
			addKeyAndContainerListenerRecursively(children[i]);
		}
	}
}