Java Code Examples for java.beans.PropertyChangeSupport#removePropertyChangeListener()

The following examples show how to use java.beans.PropertyChangeSupport#removePropertyChangeListener() . 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: Toolkit.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
    PropertyChangeSupport pcs = (PropertyChangeSupport)
            AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
    if (null != pcs) {
        pcs.removePropertyChangeListener(listener);
    }
}
 
Example 2
Source File: Toolkit.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized void removePropertyChangeListener(
        String propertyName,
        PropertyChangeListener listener)
{
    PropertyChangeSupport pcs = (PropertyChangeSupport)
            AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
    if (null != pcs) {
        pcs.removePropertyChangeListener(propertyName, listener);
    }
}
 
Example 3
Source File: Toolkit.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
    PropertyChangeSupport pcs = (PropertyChangeSupport)
            AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
    if (null != pcs) {
        pcs.removePropertyChangeListener(listener);
    }
}
 
Example 4
Source File: SharedClassObject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Removes the specified property change listener so that it
 * no longer receives property change events from this object.
 * @param         l     the property change listener
 */
public final void removePropertyChangeListener(PropertyChangeListener l) {
    boolean callRemoved;

    synchronized (getLock()) {
        PropertyChangeSupport supp = (PropertyChangeSupport) getProperty(PROP_SUPPORT);

        if (supp == null) {
            return;
        }

        boolean hasListener = supp.hasListeners(null);
        supp.removePropertyChangeListener(l);
        callRemoved = hasListener && !supp.hasListeners(null);
    }

    if (callRemoved) {
        putProperty(PROP_SUPPORT, null); // clean the PCS, see #25417
        removeNotifySuper = false;
        removeNotify();

        if (!removeNotifySuper) {
            String msg = "You must call super.removeNotify() from " + getClass().getName() + ".removeNotify()"; // NOI18N
            err.warning(msg);
        }
    }
}
 
Example 5
Source File: Toolkit.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
    PropertyChangeSupport pcs = (PropertyChangeSupport)
            AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
    if (null != pcs) {
        pcs.removePropertyChangeListener(listener);
    }
}
 
Example 6
Source File: Toolkit.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void removePropertyChangeListener(
        String propertyName,
        PropertyChangeListener listener)
{
    PropertyChangeSupport pcs = (PropertyChangeSupport)
            AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
    if (null != pcs) {
        pcs.removePropertyChangeListener(propertyName, listener);
    }
}
 
Example 7
Source File: Toolkit.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
    PropertyChangeSupport pcs = (PropertyChangeSupport)
            AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
    if (null != pcs) {
        pcs.removePropertyChangeListener(listener);
    }
}
 
Example 8
Source File: Toolkit.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized void removePropertyChangeListener(
        String propertyName,
        PropertyChangeListener listener)
{
    PropertyChangeSupport pcs = (PropertyChangeSupport)
            AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
    if (null != pcs) {
        pcs.removePropertyChangeListener(propertyName, listener);
    }
}
 
Example 9
Source File: Toolkit.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
    PropertyChangeSupport pcs = (PropertyChangeSupport)
            AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
    if (null != pcs) {
        pcs.removePropertyChangeListener(listener);
    }
}
 
Example 10
Source File: Toolkit.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
    PropertyChangeSupport pcs = (PropertyChangeSupport)
            AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
    if (null != pcs) {
        pcs.removePropertyChangeListener(listener);
    }
}
 
Example 11
Source File: Toolkit.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
    PropertyChangeSupport pcs = (PropertyChangeSupport)
            AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
    if (null != pcs) {
        pcs.removePropertyChangeListener(listener);
    }
}
 
Example 12
Source File: TestListeners.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) {
    PropertyChangeSupport pcs = new PropertyChangeSupport(TestListeners.class);
    pcs.addPropertyChangeListener(new TestListeners(0));
    pcs.addPropertyChangeListener(NAME, new TestListeners(2));
    pcs.addPropertyChangeListener(new TestListeners(1));
    pcs.addPropertyChangeListener(NAME, new PropertyChangeListenerProxy(NAME, new TestListeners(3)));


    current = 0;
    pcs.firePropertyChange(NAME, 0, 1);
    if (current != 4)
        throw new Error("Expected 4 listeners, but called " + current);

    current = 0;
    pcs.firePropertyChange(NONE, 1, 0);
    if (current != 2)
        throw new Error("Expected 2 listeners, but called " + current);


    PropertyChangeListener[] all = pcs.getPropertyChangeListeners();
    if (all.length != 4)
        throw new Error("Expected 4 listeners, but contained " + all.length);

    PropertyChangeListener[] named = pcs.getPropertyChangeListeners(NAME);
    if (named.length != 2)
        throw new Error("Expected 2 named listeners, but contained " + named.length);

    PropertyChangeListener[] other = pcs.getPropertyChangeListeners(NONE);
    if (other.length != 0)
        throw new Error("Expected 0 other listeners, but contained " + other.length);

    pcs.removePropertyChangeListener(new TestListeners(0));
    pcs.removePropertyChangeListener(new TestListeners(1));
    pcs.removePropertyChangeListener(NAME, new TestListeners(2));
    pcs.removePropertyChangeListener(NAME, new PropertyChangeListenerProxy(NAME, new TestListeners(3)));

    all = pcs.getPropertyChangeListeners();
    if (all.length != 0)
        throw new Error("Expected 4 listeners, but contained " + all.length);

    named = pcs.getPropertyChangeListeners(NAME);
    if (named.length != 0)
        throw new Error("Expected 2 named listeners, but contained " + named.length);

    other = pcs.getPropertyChangeListeners(NONE);
    if (other.length != 0)
        throw new Error("Expected 0 other listeners, but contained " + other.length);
}
 
Example 13
Source File: TestListeners.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) {
    PropertyChangeSupport pcs = new PropertyChangeSupport(TestListeners.class);
    pcs.addPropertyChangeListener(new TestListeners(0));
    pcs.addPropertyChangeListener(NAME, new TestListeners(2));
    pcs.addPropertyChangeListener(new TestListeners(1));
    pcs.addPropertyChangeListener(NAME, new PropertyChangeListenerProxy(NAME, new TestListeners(3)));


    current = 0;
    pcs.firePropertyChange(NAME, 0, 1);
    if (current != 4)
        throw new Error("Expected 4 listeners, but called " + current);

    current = 0;
    pcs.firePropertyChange(NONE, 1, 0);
    if (current != 2)
        throw new Error("Expected 2 listeners, but called " + current);


    PropertyChangeListener[] all = pcs.getPropertyChangeListeners();
    if (all.length != 4)
        throw new Error("Expected 4 listeners, but contained " + all.length);

    PropertyChangeListener[] named = pcs.getPropertyChangeListeners(NAME);
    if (named.length != 2)
        throw new Error("Expected 2 named listeners, but contained " + named.length);

    PropertyChangeListener[] other = pcs.getPropertyChangeListeners(NONE);
    if (other.length != 0)
        throw new Error("Expected 0 other listeners, but contained " + other.length);

    pcs.removePropertyChangeListener(new TestListeners(0));
    pcs.removePropertyChangeListener(new TestListeners(1));
    pcs.removePropertyChangeListener(NAME, new TestListeners(2));
    pcs.removePropertyChangeListener(NAME, new PropertyChangeListenerProxy(NAME, new TestListeners(3)));

    all = pcs.getPropertyChangeListeners();
    if (all.length != 0)
        throw new Error("Expected 4 listeners, but contained " + all.length);

    named = pcs.getPropertyChangeListeners(NAME);
    if (named.length != 0)
        throw new Error("Expected 2 named listeners, but contained " + named.length);

    other = pcs.getPropertyChangeListeners(NONE);
    if (other.length != 0)
        throw new Error("Expected 0 other listeners, but contained " + other.length);
}
 
Example 14
Source File: Coordinator.java    From PathFinder with Apache License 2.0 4 votes vote down vote up
public void removePropertyChangeListener(Object source, PropertyChangeListener listener) {
	PropertyChangeSupport support = supports.get(source);
	if (support != null) {
		support.removePropertyChangeListener(listener);
	}
}
 
Example 15
Source File: TestListeners.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) {
    PropertyChangeSupport pcs = new PropertyChangeSupport(TestListeners.class);
    pcs.addPropertyChangeListener(new TestListeners(0));
    pcs.addPropertyChangeListener(NAME, new TestListeners(2));
    pcs.addPropertyChangeListener(new TestListeners(1));
    pcs.addPropertyChangeListener(NAME, new PropertyChangeListenerProxy(NAME, new TestListeners(3)));


    current = 0;
    pcs.firePropertyChange(NAME, 0, 1);
    if (current != 4)
        throw new Error("Expected 4 listeners, but called " + current);

    current = 0;
    pcs.firePropertyChange(NONE, 1, 0);
    if (current != 2)
        throw new Error("Expected 2 listeners, but called " + current);


    PropertyChangeListener[] all = pcs.getPropertyChangeListeners();
    if (all.length != 4)
        throw new Error("Expected 4 listeners, but contained " + all.length);

    PropertyChangeListener[] named = pcs.getPropertyChangeListeners(NAME);
    if (named.length != 2)
        throw new Error("Expected 2 named listeners, but contained " + named.length);

    PropertyChangeListener[] other = pcs.getPropertyChangeListeners(NONE);
    if (other.length != 0)
        throw new Error("Expected 0 other listeners, but contained " + other.length);

    pcs.removePropertyChangeListener(new TestListeners(0));
    pcs.removePropertyChangeListener(new TestListeners(1));
    pcs.removePropertyChangeListener(NAME, new TestListeners(2));
    pcs.removePropertyChangeListener(NAME, new PropertyChangeListenerProxy(NAME, new TestListeners(3)));

    all = pcs.getPropertyChangeListeners();
    if (all.length != 0)
        throw new Error("Expected 4 listeners, but contained " + all.length);

    named = pcs.getPropertyChangeListeners(NAME);
    if (named.length != 0)
        throw new Error("Expected 2 named listeners, but contained " + named.length);

    other = pcs.getPropertyChangeListeners(NONE);
    if (other.length != 0)
        throw new Error("Expected 0 other listeners, but contained " + other.length);
}
 
Example 16
Source File: TestListeners.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) {
    PropertyChangeSupport pcs = new PropertyChangeSupport(TestListeners.class);
    pcs.addPropertyChangeListener(new TestListeners(0));
    pcs.addPropertyChangeListener(NAME, new TestListeners(2));
    pcs.addPropertyChangeListener(new TestListeners(1));
    pcs.addPropertyChangeListener(NAME, new PropertyChangeListenerProxy(NAME, new TestListeners(3)));


    current = 0;
    pcs.firePropertyChange(NAME, 0, 1);
    if (current != 4)
        throw new Error("Expected 4 listeners, but called " + current);

    current = 0;
    pcs.firePropertyChange(NONE, 1, 0);
    if (current != 2)
        throw new Error("Expected 2 listeners, but called " + current);


    PropertyChangeListener[] all = pcs.getPropertyChangeListeners();
    if (all.length != 4)
        throw new Error("Expected 4 listeners, but contained " + all.length);

    PropertyChangeListener[] named = pcs.getPropertyChangeListeners(NAME);
    if (named.length != 2)
        throw new Error("Expected 2 named listeners, but contained " + named.length);

    PropertyChangeListener[] other = pcs.getPropertyChangeListeners(NONE);
    if (other.length != 0)
        throw new Error("Expected 0 other listeners, but contained " + other.length);

    pcs.removePropertyChangeListener(new TestListeners(0));
    pcs.removePropertyChangeListener(new TestListeners(1));
    pcs.removePropertyChangeListener(NAME, new TestListeners(2));
    pcs.removePropertyChangeListener(NAME, new PropertyChangeListenerProxy(NAME, new TestListeners(3)));

    all = pcs.getPropertyChangeListeners();
    if (all.length != 0)
        throw new Error("Expected 4 listeners, but contained " + all.length);

    named = pcs.getPropertyChangeListeners(NAME);
    if (named.length != 0)
        throw new Error("Expected 2 named listeners, but contained " + named.length);

    other = pcs.getPropertyChangeListeners(NONE);
    if (other.length != 0)
        throw new Error("Expected 0 other listeners, but contained " + other.length);
}
 
Example 17
Source File: TestListeners.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) {
    PropertyChangeSupport pcs = new PropertyChangeSupport(TestListeners.class);
    pcs.addPropertyChangeListener(new TestListeners(0));
    pcs.addPropertyChangeListener(NAME, new TestListeners(2));
    pcs.addPropertyChangeListener(new TestListeners(1));
    pcs.addPropertyChangeListener(NAME, new PropertyChangeListenerProxy(NAME, new TestListeners(3)));


    current = 0;
    pcs.firePropertyChange(NAME, 0, 1);
    if (current != 4)
        throw new Error("Expected 4 listeners, but called " + current);

    current = 0;
    pcs.firePropertyChange(NONE, 1, 0);
    if (current != 2)
        throw new Error("Expected 2 listeners, but called " + current);


    PropertyChangeListener[] all = pcs.getPropertyChangeListeners();
    if (all.length != 4)
        throw new Error("Expected 4 listeners, but contained " + all.length);

    PropertyChangeListener[] named = pcs.getPropertyChangeListeners(NAME);
    if (named.length != 2)
        throw new Error("Expected 2 named listeners, but contained " + named.length);

    PropertyChangeListener[] other = pcs.getPropertyChangeListeners(NONE);
    if (other.length != 0)
        throw new Error("Expected 0 other listeners, but contained " + other.length);

    pcs.removePropertyChangeListener(new TestListeners(0));
    pcs.removePropertyChangeListener(new TestListeners(1));
    pcs.removePropertyChangeListener(NAME, new TestListeners(2));
    pcs.removePropertyChangeListener(NAME, new PropertyChangeListenerProxy(NAME, new TestListeners(3)));

    all = pcs.getPropertyChangeListeners();
    if (all.length != 0)
        throw new Error("Expected 4 listeners, but contained " + all.length);

    named = pcs.getPropertyChangeListeners(NAME);
    if (named.length != 0)
        throw new Error("Expected 2 named listeners, but contained " + named.length);

    other = pcs.getPropertyChangeListeners(NONE);
    if (other.length != 0)
        throw new Error("Expected 0 other listeners, but contained " + other.length);
}
 
Example 18
Source File: TestListeners.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) {
    PropertyChangeSupport pcs = new PropertyChangeSupport(TestListeners.class);
    pcs.addPropertyChangeListener(new TestListeners(0));
    pcs.addPropertyChangeListener(NAME, new TestListeners(2));
    pcs.addPropertyChangeListener(new TestListeners(1));
    pcs.addPropertyChangeListener(NAME, new PropertyChangeListenerProxy(NAME, new TestListeners(3)));


    current = 0;
    pcs.firePropertyChange(NAME, 0, 1);
    if (current != 4)
        throw new Error("Expected 4 listeners, but called " + current);

    current = 0;
    pcs.firePropertyChange(NONE, 1, 0);
    if (current != 2)
        throw new Error("Expected 2 listeners, but called " + current);


    PropertyChangeListener[] all = pcs.getPropertyChangeListeners();
    if (all.length != 4)
        throw new Error("Expected 4 listeners, but contained " + all.length);

    PropertyChangeListener[] named = pcs.getPropertyChangeListeners(NAME);
    if (named.length != 2)
        throw new Error("Expected 2 named listeners, but contained " + named.length);

    PropertyChangeListener[] other = pcs.getPropertyChangeListeners(NONE);
    if (other.length != 0)
        throw new Error("Expected 0 other listeners, but contained " + other.length);

    pcs.removePropertyChangeListener(new TestListeners(0));
    pcs.removePropertyChangeListener(new TestListeners(1));
    pcs.removePropertyChangeListener(NAME, new TestListeners(2));
    pcs.removePropertyChangeListener(NAME, new PropertyChangeListenerProxy(NAME, new TestListeners(3)));

    all = pcs.getPropertyChangeListeners();
    if (all.length != 0)
        throw new Error("Expected 4 listeners, but contained " + all.length);

    named = pcs.getPropertyChangeListeners(NAME);
    if (named.length != 0)
        throw new Error("Expected 2 named listeners, but contained " + named.length);

    other = pcs.getPropertyChangeListeners(NONE);
    if (other.length != 0)
        throw new Error("Expected 0 other listeners, but contained " + other.length);
}
 
Example 19
Source File: TestListeners.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) {
    PropertyChangeSupport pcs = new PropertyChangeSupport(TestListeners.class);
    pcs.addPropertyChangeListener(new TestListeners(0));
    pcs.addPropertyChangeListener(NAME, new TestListeners(2));
    pcs.addPropertyChangeListener(new TestListeners(1));
    pcs.addPropertyChangeListener(NAME, new PropertyChangeListenerProxy(NAME, new TestListeners(3)));


    current = 0;
    pcs.firePropertyChange(NAME, 0, 1);
    if (current != 4)
        throw new Error("Expected 4 listeners, but called " + current);

    current = 0;
    pcs.firePropertyChange(NONE, 1, 0);
    if (current != 2)
        throw new Error("Expected 2 listeners, but called " + current);


    PropertyChangeListener[] all = pcs.getPropertyChangeListeners();
    if (all.length != 4)
        throw new Error("Expected 4 listeners, but contained " + all.length);

    PropertyChangeListener[] named = pcs.getPropertyChangeListeners(NAME);
    if (named.length != 2)
        throw new Error("Expected 2 named listeners, but contained " + named.length);

    PropertyChangeListener[] other = pcs.getPropertyChangeListeners(NONE);
    if (other.length != 0)
        throw new Error("Expected 0 other listeners, but contained " + other.length);

    pcs.removePropertyChangeListener(new TestListeners(0));
    pcs.removePropertyChangeListener(new TestListeners(1));
    pcs.removePropertyChangeListener(NAME, new TestListeners(2));
    pcs.removePropertyChangeListener(NAME, new PropertyChangeListenerProxy(NAME, new TestListeners(3)));

    all = pcs.getPropertyChangeListeners();
    if (all.length != 0)
        throw new Error("Expected 4 listeners, but contained " + all.length);

    named = pcs.getPropertyChangeListeners(NAME);
    if (named.length != 0)
        throw new Error("Expected 2 named listeners, but contained " + named.length);

    other = pcs.getPropertyChangeListeners(NONE);
    if (other.length != 0)
        throw new Error("Expected 0 other listeners, but contained " + other.length);
}
 
Example 20
Source File: DocumentUtilities.java    From netbeans with Apache License 2.0 3 votes vote down vote up
/**
 * Removes <code>PropertyChangeListener</code> from a document.
 *
 * @param doc The document to remove the listener from.
 * @param l The listener to remove from the document.
 *
 * @since 1.35
 */
public static void removePropertyChangeListener(Document doc, PropertyChangeListener l) {
    PropertyChangeSupport pcs = (PropertyChangeSupport) doc.getProperty(PropertyChangeSupport.class);
    if (pcs != null) {
        pcs.removePropertyChangeListener(l);
    }
}