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

The following examples show how to use java.awt.Component#removeComponentListener() . These examples are extracted from open source projects. 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 Project: netbeans   File: EditorCaret.java    License: 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
@Override
public void removeNotify() {
    super.removeNotify();
    final Component parent = SwingUtilities.getRoot(this);
    if (parent != null){
        parent.removeComponentListener(componentListener);
    }
}
 
Example 3
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 Project: settlers-remake   File: GOSwingEventConverter.java    License: 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 5
Source Project: JDKSourceCode1.8   File: AncestorNotifier.java    License: 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 6
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 7
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 Project: netbeans   File: BaseCaret.java    License: 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 9
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 Project: Bytecoder   File: AncestorNotifier.java    License: 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 11
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
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 Project: Java8CN   File: AncestorNotifier.java    License: 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 14
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
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
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 17
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 18
Source Project: pumpernickel   File: BoxTabbedPaneUI.java    License: 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 19
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 20
private void onComponentRemoted(ContainerEvent event) {
    Component removedComponent = event.getChild();
    if (removedComponent instanceof JInternalFrame)
        removedComponent.removeComponentListener(componentListener);

}