當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。