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


Java PropertyChangeSupport.firePropertyChange方法代码示例

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


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

示例1: main

import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
public static void main(String[] args) {
    TestEquals one = new TestEquals(1);
    TestEquals two = new TestEquals(2);

    Object source = TestEquals.class;
    PropertyChangeSupport pcs = new PropertyChangeSupport(source);
    pcs.addPropertyChangeListener(PROPERTY, one);
    pcs.addPropertyChangeListener(PROPERTY, two);

    PropertyChangeEvent event = new PropertyChangeEvent(source, PROPERTY, one, two);
    pcs.firePropertyChange(event);
    test(one, two, 1); // only one check
    pcs.firePropertyChange(PROPERTY, one, two);
    test(one, two, 2); // because it invokes firePropertyChange(PropertyChangeEvent)
    pcs.fireIndexedPropertyChange(PROPERTY, 1, one, two);
    test(one, two, 2); // because it invokes firePropertyChange(PropertyChangeEvent)
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:TestEquals.java

示例2: MissingNbInstallationProblemProvider

import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
public MissingNbInstallationProblemProvider(Project prj) {
    pchs = new PropertyChangeSupport(this);
    project = prj;
    propertyListener = new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (OpenProjects.PROPERTY_OPEN_PROJECTS.equals(evt.getPropertyName()) && OpenProjects.getDefault().isProjectOpen(project)) {
                pchs.firePropertyChange(PROP_PROBLEMS, null, null);
            }
            if (NbMavenProject.PROP_PROJECT.equals(evt.getPropertyName())) {
                pchs.firePropertyChange(PROP_PROBLEMS, null, null);
            }
        }
    };
    weak = WeakListeners.propertyChange(propertyListener, this);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:MissingNbInstallationProblemProvider.java

示例3: firePropertyChange

import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
@Override
public void firePropertyChange(final PropertyChangeEvent evt) {
    Object oldValue = evt.getOldValue();
    Object newValue = evt.getNewValue();
    String propertyName = evt.getPropertyName();
    if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
        return;
    }
    Runnable updater = new Runnable() {
        public void run() {
            PropertyChangeSupport pcs = (PropertyChangeSupport)
                    AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
            if (null != pcs) {
                pcs.firePropertyChange(evt);
            }
        }
    };
    final AppContext currentAppContext = AppContext.getAppContext();
    for (AppContext appContext : AppContext.getAppContexts()) {
        if (null == appContext || appContext.isDisposed()) {
            continue;
        }
        if (currentAppContext == appContext) {
            updater.run();
        } else {
            final PeerEvent e = new PeerEvent(source, updater, PeerEvent.ULTIMATE_PRIORITY_EVENT);
            SunToolkit.postEvent(appContext, e);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:Toolkit.java

示例4: processEvent

import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
static void processEvent(XoaEvent event) {
    LOG.entering(CLASS_NAME, "dispatchEventToXoa", event);
    LOG.log(Level.FINEST, "SOA --> XOA: {1}", event);

    Integer handlerId = event.getHandlerId();
    if (handlerId == null) {
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("Null handlerId");
        }
        return;
    }
    
    String eventType = event.getKind().toString();
    Object[] params = event.getParams();
    Object[] args = { handlerId, eventType, params };
    PropertyChangeSupport xop = getCrossOriginProxy(handlerId);
    if (xop == null) {
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("Null xop for handler " + handlerId);
        }
        return;
    }
    
    xop.firePropertyChange(SOA_MESSAGE, null, args);
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:26,代码来源:BridgeUtil.java

示例5: put

import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
public @Override Object put(Object key, Object value) {
     if (key == PropertyChangeSupport.class && value instanceof PropertyChangeSupport) {
         pcs = (PropertyChangeSupport) value;
     }

     Object old = null;
     boolean usePlainPut = true;

      if (key != null) {
          Object val = super.get(key);
          if (val instanceof BaseDocument_PropertyHandler) {
              old = ((BaseDocument_PropertyHandler) val).setValue(value);
              usePlainPut = false;
          }
      }

     if (usePlainPut) {
         old = super.put(key, value);
     }

     if (key instanceof String) {
         if (pcs != null) {
             pcs.firePropertyChange((String) key, old, value);
         }
     }

     return old;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:BaseDocument.java

示例6: firePropertyChange

import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
/** Fire a property change event to all listeners.
* @param name the name of the property
* @param oldValue the old value
* @param newValue the new value
*/

// not final - SystemOption overrides it, e.g.
protected void firePropertyChange(String name, Object oldValue, Object newValue) {
    PropertyChangeSupport supp = (PropertyChangeSupport) getProperty(PROP_SUPPORT);

    if (supp != null) {
        supp.firePropertyChange(name, oldValue, newValue);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:SharedClassObject.java

示例7: updateState

import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
void updateState(ActionMap prev, ActionMap now, boolean fire) {
    if (key == null) {
        return;
    }

    boolean prevEnabled = false;
    if (prev != null) {
        Action prevAction = prev.get(key);
        if (prevAction != null) {
            prevEnabled = fire && prevAction.isEnabled();
            prevAction.removePropertyChangeListener(weakL);
        }
    }
    if (now != null) {
        Action nowAction = now.get(key);
        boolean nowEnabled;
        if (nowAction != null) {
            nowAction.addPropertyChangeListener(weakL);
            nowEnabled = nowAction.isEnabled();
        } else {
            nowEnabled = fallback != null && fallback.isEnabled();
        }
        PropertyChangeSupport sup = fire ? support : null;
        if (sup != null && nowEnabled != prevEnabled) {
            sup.firePropertyChange("enabled", prevEnabled, !prevEnabled); // NOI18N
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:GeneralAction.java

示例8: updateState

import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
void updateState() {
    PropertyChangeSupport s;
    synchronized (this) {
        s = support;
    }
    boolean prev = previousEnabled;
    if (s != null && prev != isEnabled()) {
        s.firePropertyChange("enabled", Boolean.valueOf(prev), Boolean.valueOf(!prev)); // NOI18N
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ContextAction.java

示例9: firePropertyChange

import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
/**
 * Support for reporting bound property changes for Object properties.
 * This method can be called when a bound property has changed and it will
 * send the appropriate PropertyChangeEvent to any registered
 * PropertyChangeListeners.
 *
 * @param propertyName the property whose value has changed
 * @param oldValue the property's previous value
 * @param newValue the property's new value
 */
protected void firePropertyChange(String propertyName,
                                  Object oldValue, Object newValue) {
    PropertyChangeSupport changeSupport;
    synchronized (getObjectLock()) {
        changeSupport = this.changeSupport;
    }
    if (changeSupport == null ||
        (oldValue != null && newValue != null && oldValue.equals(newValue))) {
        return;
    }
    changeSupport.firePropertyChange(propertyName, oldValue, newValue);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:Component.java

示例10: firePropertyChange

import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
/**
 * Fires a PropertyChangeEvent in response to a change in a bound property.
 * The event will be delivered to all registered PropertyChangeListeners.
 * No event will be delivered if oldValue and newValue are the same.
 *
 * @param propertyName the name of the property that has changed
 * @param oldValue the property's previous value
 * @param newValue the property's new value
 */
protected void firePropertyChange(String propertyName, Object oldValue,
                                  Object newValue)
{
    if (oldValue == newValue) {
        return;
    }
    PropertyChangeSupport changeSupport = this.changeSupport;
    if (changeSupport != null) {
        changeSupport.firePropertyChange(propertyName, oldValue, newValue);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:KeyboardFocusManager.java

示例11: 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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:49,代码来源:TestListeners.java


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