java.beans.PropertyChangeListenerProxy Java Examples
The following examples show how to use
java.beans.PropertyChangeListenerProxy.
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: ResourceTable.java From netbeans with Apache License 2.0 | 6 votes |
/** * Add a PropertyChangeListener to the listener list. The listener is * registered for all properties. The same listener object may be added * more than once, and will be called as many times as it is added. If * listener is null, no exception is thrown and no action is taken. * * @param listener The PropertyChangeListener to be added */ public void addPropertyChangeListener(PropertyChangeListener listener) { if (listener instanceof PropertyChangeListenerProxy) { PropertyChangeListenerProxy proxy = (PropertyChangeListenerProxy) listener; addPropertyChangeListener(proxy.getPropertyName(), (PropertyChangeListener)proxy.getListener()); } else { listeners.add(new WeakReference<PropertyChangeListener>(listener)); } }
Example #2
Source File: TestSerialization.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void check(PropertyChangeListener listener, int index, String name) { if (!(listener instanceof PropertyChangeListenerProxy)) throw new Error("Unexpected listener: " + listener); PropertyChangeListenerProxy object = (PropertyChangeListenerProxy)listener; if (!name.equals(object.getPropertyName())) throw new Error("Unexpected name: " + name + " != " + object.getPropertyName()); check((PropertyChangeListener)object.getListener(), index); }
Example #3
Source File: PropertyChangeListenerProxyTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * Regression for HARMONY-407 */ public void testPropertyChange_PropertyChangeEvent() { PropertyChangeListenerProxy proxy = new PropertyChangeListenerProxy( "harmony", null); try { proxy.propertyChange(null); fail("NullPointerException expected"); } catch (NullPointerException e) { } }
Example #4
Source File: TestSerialization.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private static void check(PropertyChangeListener listener, int index, String name) { if (!(listener instanceof PropertyChangeListenerProxy)) throw new Error("Unexpected listener: " + listener); PropertyChangeListenerProxy object = (PropertyChangeListenerProxy)listener; if (!name.equals(object.getPropertyName())) throw new Error("Unexpected name: " + name + " != " + object.getPropertyName()); check((PropertyChangeListener)object.getListener(), index); }
Example #5
Source File: TestSerialization.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void check(PropertyChangeListener listener, int index, String name) { if (!(listener instanceof PropertyChangeListenerProxy)) throw new Error("Unexpected listener: " + listener); PropertyChangeListenerProxy object = (PropertyChangeListenerProxy)listener; if (!name.equals(object.getPropertyName())) throw new Error("Unexpected name: " + name + " != " + object.getPropertyName()); check((PropertyChangeListener)object.getListener(), index); }
Example #6
Source File: TestSerialization.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static void check(PropertyChangeListener listener, int index, String name) { if (!(listener instanceof PropertyChangeListenerProxy)) throw new Error("Unexpected listener: " + listener); PropertyChangeListenerProxy object = (PropertyChangeListenerProxy)listener; if (!name.equals(object.getPropertyName())) throw new Error("Unexpected name: " + name + " != " + object.getPropertyName()); check((PropertyChangeListener)object.getListener(), index); }
Example #7
Source File: TestSerialization.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static void check(PropertyChangeListener listener, int index, String name) { if (!(listener instanceof PropertyChangeListenerProxy)) throw new Error("Unexpected listener: " + listener); PropertyChangeListenerProxy object = (PropertyChangeListenerProxy)listener; if (!name.equals(object.getPropertyName())) throw new Error("Unexpected name: " + name + " != " + object.getPropertyName()); check((PropertyChangeListener)object.getListener(), index); }
Example #8
Source File: TestSerialization.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private static void check(PropertyChangeListener listener, int index, String name) { if (!(listener instanceof PropertyChangeListenerProxy)) throw new Error("Unexpected listener: " + listener); PropertyChangeListenerProxy object = (PropertyChangeListenerProxy)listener; if (!name.equals(object.getPropertyName())) throw new Error("Unexpected name: " + name + " != " + object.getPropertyName()); check((PropertyChangeListener)object.getListener(), index); }
Example #9
Source File: TestSerialization.java From hottub with GNU General Public License v2.0 | 5 votes |
private static void check(PropertyChangeListener listener, int index, String name) { if (!(listener instanceof PropertyChangeListenerProxy)) throw new Error("Unexpected listener: " + listener); PropertyChangeListenerProxy object = (PropertyChangeListenerProxy)listener; if (!name.equals(object.getPropertyName())) throw new Error("Unexpected name: " + name + " != " + object.getPropertyName()); check((PropertyChangeListener)object.getListener(), index); }
Example #10
Source File: TestSerialization.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void check(PropertyChangeListener listener, int index, String name) { if (!(listener instanceof PropertyChangeListenerProxy)) throw new Error("Unexpected listener: " + listener); PropertyChangeListenerProxy object = (PropertyChangeListenerProxy)listener; if (!name.equals(object.getPropertyName())) throw new Error("Unexpected name: " + name + " != " + object.getPropertyName()); check((PropertyChangeListener)object.getListener(), index); }
Example #11
Source File: TestSerialization.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static void check(PropertyChangeListener listener, int index, String name) { if (!(listener instanceof PropertyChangeListenerProxy)) throw new Error("Unexpected listener: " + listener); PropertyChangeListenerProxy object = (PropertyChangeListenerProxy)listener; if (!name.equals(object.getPropertyName())) throw new Error("Unexpected name: " + name + " != " + object.getPropertyName()); check((PropertyChangeListener)object.getListener(), index); }
Example #12
Source File: TestSerialization.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static void check(PropertyChangeListener listener, int index, String name) { if (!(listener instanceof PropertyChangeListenerProxy)) throw new Error("Unexpected listener: " + listener); PropertyChangeListenerProxy object = (PropertyChangeListenerProxy)listener; if (!name.equals(object.getPropertyName())) throw new Error("Unexpected name: " + name + " != " + object.getPropertyName()); check((PropertyChangeListener)object.getListener(), index); }
Example #13
Source File: TestSerialization.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void check(PropertyChangeListener listener, int index, String name) { if (!(listener instanceof PropertyChangeListenerProxy)) throw new Error("Unexpected listener: " + listener); PropertyChangeListenerProxy object = (PropertyChangeListenerProxy)listener; if (!name.equals(object.getPropertyName())) throw new Error("Unexpected name: " + name + " != " + object.getPropertyName()); check((PropertyChangeListener)object.getListener(), index); }
Example #14
Source File: TestSerialization.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static void check(PropertyChangeListener listener, int index, String name) { if (!(listener instanceof PropertyChangeListenerProxy)) throw new Error("Unexpected listener: " + listener); PropertyChangeListenerProxy object = (PropertyChangeListenerProxy)listener; if (!name.equals(object.getPropertyName())) throw new Error("Unexpected name: " + name + " != " + object.getPropertyName()); check((PropertyChangeListener)object.getListener(), index); }
Example #15
Source File: TestSerialization.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static void check(PropertyChangeListener listener, int index, String name) { if (!(listener instanceof PropertyChangeListenerProxy)) throw new Error("Unexpected listener: " + listener); PropertyChangeListenerProxy object = (PropertyChangeListenerProxy)listener; if (!name.equals(object.getPropertyName())) throw new Error("Unexpected name: " + name + " != " + object.getPropertyName()); check((PropertyChangeListener)object.getListener(), index); }
Example #16
Source File: TestListeners.java From openjdk-8 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 #17
Source File: PropertyChangeListenerProxyTest.java From j2objc with Apache License 2.0 | 4 votes |
@Override protected void setUp() throws Exception { super.setUp(); proxy = new PropertyChangeListenerProxy(name, listener); }
Example #18
Source File: TestListeners.java From TencentKona-8 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 jdk8u-dev-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 #20
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 #21
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 #22
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 #23
Source File: TestListeners.java From openjdk-jdk8u 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 #24
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); }
Example #25
Source File: TestListeners.java From hottub 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 #26
Source File: TestListeners.java From dragonwell8_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 #27
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 #28
Source File: TestListeners.java From openjdk-jdk8u-backup 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 #29
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); }