Java Code Examples for java.awt.Component#removeComponentListener()

The following examples show how to use java.awt.Component#removeComponentListener() . 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: EditorCaret.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * May be called for either component or horizontal scrollbar.
 */
public @Override void componentResized(ComponentEvent e) {
    Component c = e.getComponent();
    if (c == component) { // called for component
        // In case the caretBounds are still null
        // (component not connected to hierarchy yet or it has zero size
        // so the modelToView() returned null) re-attempt to compute the bounds.
        CaretItem caret = getLastCaretItem();
        if (caret.getCaretBounds() == null) {
            dispatchUpdate(false);
            resetBlink();
            if (caret.getCaretBounds() != null) { // detach the listener - no longer necessary
                c.removeComponentListener(this);
            }
        }
    }
}
 
Example 2
Source File: AncestorNotifier.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
void removeListeners(Component ancestor) {
    Component a;
    for (a = ancestor; a != null; a = a.getParent()) {
        a.removeComponentListener(this);
        if (a instanceof JComponent) {
            JComponent jAncestor = (JComponent)a;
            jAncestor.removePropertyChangeListener(this);
        }
        if (a == firstInvisibleAncestor || a instanceof Window) {
            break;
        }
    }
}
 
Example 3
Source File: AncestorNotifier.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
void removeListeners(Component ancestor) {
    Component a;
    for (a = ancestor; a != null; a = a.getParent()) {
        a.removeComponentListener(this);
        if (a instanceof JComponent) {
            JComponent jAncestor = (JComponent)a;
            jAncestor.removePropertyChangeListener(this);
        }
        if (a == firstInvisibleAncestor || a instanceof Window) {
            break;
        }
    }
}
 
Example 4
Source File: BoxTabbedPaneUI.java    From pumpernickel with MIT License 5 votes vote down vote up
private void installExtraComponents(Container container,
		List<JComponent> components, boolean forceReinstall) {
	if (components == null)
		components = new ArrayList<>();
	Component[] oldComponents = container.getComponents();
	if (!Arrays.asList(oldComponents).equals(components)) {
		forceReinstall = true;
	}

	if (forceReinstall) {
		container.removeAll();
		GridBagConstraints c = new GridBagConstraints();
		c.gridx = 0;
		c.gridy = 100;
		c.weightx = 1;
		c.weighty = 1;
		c.fill = GridBagConstraints.BOTH;
		for (JComponent jc : components) {
			container.add(jc, c);
			if (tabs.getTabPlacement() == SwingConstants.LEFT) {
				c.gridy--;
			} else if (tabs.getTabPlacement() == SwingConstants.RIGHT) {
				c.gridy++;
			} else {
				c.gridx++;
			}
			jc.removeComponentListener(extraComponentListener);
			jc.addComponentListener(extraComponentListener);

			for (Component oldComponent : oldComponents) {
				if (components.contains(oldComponent)) {
					oldComponent
							.removeComponentListener(extraComponentListener);
				}
			}
		}
		container.revalidate();
	}
	refreshExtraContainerVisibility();
}
 
Example 5
Source File: AncestorNotifier.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
void removeListeners(Component ancestor) {
    Component a;
    for (a = ancestor; a != null; a = a.getParent()) {
        a.removeComponentListener(this);
        if (a instanceof JComponent) {
            JComponent jAncestor = (JComponent)a;
            jAncestor.removePropertyChangeListener(this);
        }
        if (a == firstInvisibleAncestor || a instanceof Window) {
            break;
        }
    }
}
 
Example 6
Source File: JExtendedSplitPane.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private void unregisterListeners(Component component) {
    if (splitPaneComponentListener != null) {
        component.removeComponentListener(splitPaneComponentListener);
    }

    if (splitPaneActionListener != null) {
        if (component instanceof JTitledPanel) {
            ((JTitledPanel) component).removeActionListener(splitPaneActionListener);
        }

        //else if (component instanceof JExtendedSplitPane) ((JTitledPanel)component).removeActionListener(splitPaneActionListener);
    }
}
 
Example 7
Source File: AncestorNotifier.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
void removeListeners(Component ancestor) {
    Component a;
    for (a = ancestor; a != null; a = a.getParent()) {
        a.removeComponentListener(this);
        if (a instanceof JComponent) {
            JComponent jAncestor = (JComponent)a;
            jAncestor.removePropertyChangeListener(this);
        }
        if (a == firstInvisibleAncestor || a instanceof Window) {
            break;
        }
    }
}
 
Example 8
Source File: AncestorNotifier.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
void removeListeners(Component ancestor) {
    Component a;
    for (a = ancestor; a != null; a = a.getParent()) {
        a.removeComponentListener(this);
        if (a instanceof JComponent) {
            JComponent jAncestor = (JComponent)a;
            jAncestor.removePropertyChangeListener(this);
        }
        if (a == firstInvisibleAncestor || a instanceof Window) {
            break;
        }
    }
}
 
Example 9
Source File: AncestorNotifier.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
void removeListeners(Component ancestor) {
    Component a;
    for (a = ancestor; a != null; a = a.getParent()) {
        a.removeComponentListener(this);
        if (a instanceof JComponent) {
            JComponent jAncestor = (JComponent)a;
            jAncestor.removePropertyChangeListener(this);
        }
        if (a == firstInvisibleAncestor || a instanceof Window) {
            break;
        }
    }
}
 
Example 10
Source File: AncestorNotifier.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
void removeListeners(Component ancestor) {
    Component a;
    for (a = ancestor; a != null; a = a.getParent()) {
        a.removeComponentListener(this);
        if (a instanceof JComponent) {
            JComponent jAncestor = (JComponent)a;
            jAncestor.removePropertyChangeListener(this);
        }
        if (a == firstInvisibleAncestor || a instanceof Window) {
            break;
        }
    }
}
 
Example 11
Source File: AncestorNotifier.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
void removeListeners(Component ancestor) {
    Component a;
    for (a = ancestor; a != null; a = a.getParent()) {
        a.removeComponentListener(this);
        if (a instanceof JComponent) {
            JComponent jAncestor = (JComponent)a;
            jAncestor.removePropertyChangeListener(this);
        }
        if (a == firstInvisibleAncestor || a instanceof Window) {
            break;
        }
    }
}
 
Example 12
Source File: AncestorNotifier.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
void removeListeners(Component ancestor) {
    Component a;
    for (a = ancestor; a != null; a = a.getParent()) {
        a.removeComponentListener(this);
        if (a instanceof JComponent) {
            JComponent jAncestor = (JComponent)a;
            jAncestor.removePropertyChangeListener(this);
        }
        if (a == firstInvisibleAncestor || a instanceof Window) {
            break;
        }
    }
}
 
Example 13
Source File: BaseCaret.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * May be called for either component or horizontal scrollbar.
 */
public @Override void componentResized(ComponentEvent e) {
    Component c = e.getComponent();
    if (c == component) { // called for component
        // In case the caretBounds are still null
        // (component not connected to hierarchy yet or it has zero size
        // so the modelToView() returned null) re-attempt to compute the bounds.
        if (caretBounds == null) {
            dispatchUpdate(true);
            if (caretBounds != null) { // detach the listener - no longer necessary
                c.removeComponentListener(this);
            }
        }
    }
}
 
Example 14
Source File: AncestorNotifier.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
void removeListeners(Component ancestor) {
    Component a;
    for (a = ancestor; a != null; a = a.getParent()) {
        a.removeComponentListener(this);
        if (a instanceof JComponent) {
            JComponent jAncestor = (JComponent)a;
            jAncestor.removePropertyChangeListener(this);
        }
        if (a == firstInvisibleAncestor || a instanceof Window) {
            break;
        }
    }
}
 
Example 15
Source File: AncestorNotifier.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
void removeListeners(Component ancestor) {
    Component a;
    for (a = ancestor; a != null; a = a.getParent()) {
        a.removeComponentListener(this);
        if (a instanceof JComponent) {
            JComponent jAncestor = (JComponent)a;
            jAncestor.removePropertyChangeListener(this);
        }
        if (a == firstInvisibleAncestor || a instanceof Window) {
            break;
        }
    }
}
 
Example 16
Source File: AncestorNotifier.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
void removeListeners(Component ancestor) {
    Component a;
    for (a = ancestor; a != null; a = a.getParent()) {
        a.removeComponentListener(this);
        if (a instanceof JComponent) {
            JComponent jAncestor = (JComponent)a;
            jAncestor.removePropertyChangeListener(this);
        }
        if (a == firstInvisibleAncestor || a instanceof Window) {
            break;
        }
    }
}
 
Example 17
Source File: GOSwingEventConverter.java    From settlers-remake with MIT License 5 votes vote down vote up
void privateRegisterComponentListenerToParentWindowOf(Component component, Component childComponent) {
	if (component == null) {
		return;
	} else if (component instanceof Window) {
		updateScaleFactor(component);
		component.addComponentListener(this);
		childComponent.removeComponentListener(this);
	} else {
		privateRegisterComponentListenerToParentWindowOf(component.getParent(), childComponent);
	}
}
 
Example 18
Source File: AncestorNotifier.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
void removeListeners(Component ancestor) {
    Component a;
    for (a = ancestor; a != null; a = a.getParent()) {
        a.removeComponentListener(this);
        if (a instanceof JComponent) {
            JComponent jAncestor = (JComponent)a;
            jAncestor.removePropertyChangeListener(this);
        }
        if (a == firstInvisibleAncestor || a instanceof Window) {
            break;
        }
    }
}
 
Example 19
Source File: SwingDialog.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void removeNotify() {
    super.removeNotify();
    final Component parent = SwingUtilities.getRoot(this);
    if (parent != null){
        parent.removeComponentListener(componentListener);
    }
}
 
Example 20
Source File: DesktopScrollPane.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
private void onComponentRemoted(ContainerEvent event) {
    Component removedComponent = event.getChild();
    if (removedComponent instanceof JInternalFrame)
        removedComponent.removeComponentListener(componentListener);

}