Java Code Examples for java.beans.PropertyChangeSupport#firePropertyChange()
The following examples show how to use
java.beans.PropertyChangeSupport#firePropertyChange() .
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: TestEquals.java From dragonwell8_jdk with GNU General Public License v2.0 | 10 votes |
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) }
Example 2
Source File: TestEquals.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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) }
Example 3
Source File: TestEquals.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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) }
Example 4
Source File: TestEquals.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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) }
Example 5
Source File: KeyboardFocusManager.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example 6
Source File: LastChange.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
synchronized public void fire(PropertyChangeSupport propertyChangeSupport) { String lastChanges = toString(); if (lastChanges != null && lastChanges.length() > 0) { propertyChangeSupport.firePropertyChange("LastChange", previousValue, lastChanges); reset(); } }
Example 7
Source File: Toolkit.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@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); } } }
Example 8
Source File: KeyboardFocusManager.java From Java8CN with Apache License 2.0 | 5 votes |
/** * 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); } }
Example 9
Source File: LastChange.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
synchronized public void fire(PropertyChangeSupport propertyChangeSupport) { String lastChanges = toString(); if (lastChanges != null && lastChanges.length() > 0) { propertyChangeSupport.firePropertyChange("LastChange", previousValue, lastChanges); reset(); } }
Example 10
Source File: Toolkit.java From JDKSourceCode1.8 with MIT License | 5 votes |
@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); } } }
Example 11
Source File: KeyboardFocusManager.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example 12
Source File: KeyboardFocusManager.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * 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); } }
Example 13
Source File: GeneralAction.java From netbeans with Apache License 2.0 | 5 votes |
public void propertyChange(PropertyChangeEvent evt) { if ("enabled".equals(evt.getPropertyName())) { // NOI18N LOG.log(Level.FINE, "Action {0}: got property change from fallback {1}", new Object[] { this, fallback }); PropertyChangeSupport sup; synchronized (this) { sup = support; } if (sup != null) { sup.firePropertyChange("enabled", evt.getOldValue(), evt.getNewValue()); // NOI18N } } }
Example 14
Source File: Toolkit.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@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); } } }
Example 15
Source File: Toolkit.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@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); } } }
Example 16
Source File: Toolkit.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@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); } } }
Example 17
Source File: TestListeners.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
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 jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
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 openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
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: TestListeners.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
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); }