当前位置: 首页>>代码示例>>Java>>正文


Java PropertyChangeSupport.removePropertyChangeListener方法代码示例

本文整理汇总了Java中java.beans.PropertyChangeSupport.removePropertyChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyChangeSupport.removePropertyChangeListener方法的具体用法?Java PropertyChangeSupport.removePropertyChangeListener怎么用?Java PropertyChangeSupport.removePropertyChangeListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.beans.PropertyChangeSupport的用法示例。


在下文中一共展示了PropertyChangeSupport.removePropertyChangeListener方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removePropertyChangeListener

import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
/**
 * 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);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:SharedClassObject.java

示例2: removePropertyChangeListener

import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
/**
 * Remove a PropertyChangeListener from this context dispatcher.
 * @param l The PropertyChangeListener
 */
public void removePropertyChangeListener(PropertyChangeListener l) {
    pcs.removePropertyChangeListener(l);
    // Also remove the listener from all MIME types
    synchronized (pcsByMIMEType) {
        Set<String> MIMETypes = new HashSet(pcsByMIMEType.keySet());
        for (String MIMEType : MIMETypes) {
            PropertyChangeSupport _pcs = pcsByMIMEType.get(MIMEType);
            _pcs.removePropertyChangeListener(l);
            if (_pcs.getPropertyChangeListeners().length == 0) {
                pcsByMIMEType.remove(MIMEType);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:EditorContextDispatcher.java

示例3: removePropertyChangeListener

import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
@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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:Toolkit.java

示例4: main

import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:49,代码来源:TestListeners.java

示例5: removePropertyChangeListener

import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:DocumentUtilities.java


注:本文中的java.beans.PropertyChangeSupport.removePropertyChangeListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。