Java 8 PropertyChangeListenerProxy - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 PropertyChangeListenerProxy class.

This code example shows how to use the following methods:getPropertyName, propertyChange, getListener
This code example shows how to use the following methods:getPropertyName, getListener
    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);
    } 
 
    private static byte[] read(String file) throws Exception {
        FileInputStream stream = null;
        try { 
            stream = new FileInputStream(new File(System.getProperty("test.src", "."), file));
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            for (int i = stream.read(); i != -1; i = stream.read())
                out.write(i);
 
            return out.toByteArray();
6
CodeRank
This code example shows how to use the following methods:getPropertyName, getListener
    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); 
    } 
 
    private static byte[] read(String file) throws Exception { 
        FileInputStream stream = null; 
        try { 
            stream = new FileInputStream(new File(System.getProperty("test.src", "."), file)); 
            ByteArrayOutputStream out = new ByteArrayOutputStream(); 
            for (int i = stream.read(); i != -1; i = stream.read()) 
                out.write(i); 
 
            return out.toByteArray(); 
5
CodeRank
This code example shows how to use the following methods:getPropertyName, getListener
    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);
    } 
 
    private static byte[] read(String file) throws Exception {
        FileInputStream stream = null;
        try { 
            stream = new FileInputStream(new File(System.getProperty("test.src", "."), file));
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            for (int i = stream.read(); i != -1; i = stream.read())
                out.write(i);
 
            return out.toByteArray();
5
CodeRank
This code example shows how to use the following methods:getPropertyName, getListener
	 * @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 { 
			if (listeners == null) {
				listeners = new EventListenerList();
			} 
			listeners.add(PropertyChangeListener.class, listener);
		} 
	} 
 
	/** 
	 * Remove a PropertyChangeListener from the listener list. This removes a 
	 * PropertyChangeListener that was registered for all properties. 
	 * 
	 * @param listener The PropertyChangeListener to be removed 
5
CodeRank
This code example shows how to use the following methods:getPropertyName, getListener
	 * @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 { 
			if (listeners == null) { 
				listeners = new EventListenerList(); 
			} 
			listeners.add(PropertyChangeListener.class, listener); 
		} 
	} 
 
	/** 
	 * Remove a PropertyChangeListener from the listener list. This removes a 
	 * PropertyChangeListener that was registered for all properties. 
	 * 
	 * @param listener The PropertyChangeListener to be removed 
4
CodeRank
This code example shows how to use the following methods:
    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();
4
CodeRank
This code example shows how to use the following methods:
    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();
4
CodeRank
This code example shows how to use the following methods:
3
CodeRank
See Code Examples for Java 8 PropertyChangeListenerProxy Methods: