Java Code Examples for java.beans.PropertyChangeListener#propertyChange()

The following examples show how to use java.beans.PropertyChangeListener#propertyChange() . 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: EnumEditor.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void setValue( Object value ) {
    if ( ( value != null ) && !this.type.isInstance( value ) ) {
        throw new IllegalArgumentException( "Unsupported value: " + value );
    }
    Object oldValue;
    PropertyChangeListener[] listeners;
    synchronized ( this.listeners ) {
        oldValue = this.value;
        this.value = value;

        if ( ( value == null ) ? oldValue == null : value.equals( oldValue ) ) {
            return; // do not fire event if value is not changed
        }
        int size = this.listeners.size();
        if ( size == 0 ) {
            return; // do not fire event if there are no any listener
        }
        listeners = this.listeners.toArray( new PropertyChangeListener[size] );
    }
    PropertyChangeEvent event = new PropertyChangeEvent( this, null, oldValue, value );
    for ( PropertyChangeListener listener : listeners ) {
        listener.propertyChange( event );
    }
}
 
Example 2
Source File: EnumEditor.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void setValue( Object value ) {
    if ( ( value != null ) && !this.type.isInstance( value ) ) {
        throw new IllegalArgumentException( "Unsupported value: " + value );
    }
    Object oldValue;
    PropertyChangeListener[] listeners;
    synchronized ( this.listeners ) {
        oldValue = this.value;
        this.value = value;

        if ( ( value == null ) ? oldValue == null : value.equals( oldValue ) ) {
            return; // do not fire event if value is not changed
        }
        int size = this.listeners.size();
        if ( size == 0 ) {
            return; // do not fire event if there are no any listener
        }
        listeners = this.listeners.toArray( new PropertyChangeListener[size] );
    }
    PropertyChangeEvent event = new PropertyChangeEvent( this, null, oldValue, value );
    for ( PropertyChangeListener listener : listeners ) {
        listener.propertyChange( event );
    }
}
 
Example 3
Source File: EnumEditor.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void setValue( Object value ) {
    if ( ( value != null ) && !this.type.isInstance( value ) ) {
        throw new IllegalArgumentException( "Unsupported value: " + value );
    }
    Object oldValue;
    PropertyChangeListener[] listeners;
    synchronized ( this.listeners ) {
        oldValue = this.value;
        this.value = value;

        if ( ( value == null ) ? oldValue == null : value.equals( oldValue ) ) {
            return; // do not fire event if value is not changed
        }
        int size = this.listeners.size();
        if ( size == 0 ) {
            return; // do not fire event if there are no any listener
        }
        listeners = this.listeners.toArray( new PropertyChangeListener[size] );
    }
    PropertyChangeEvent event = new PropertyChangeEvent( this, null, oldValue, value );
    for ( PropertyChangeListener listener : listeners ) {
        listener.propertyChange( event );
    }
}
 
Example 4
Source File: EnumEditor.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void setValue( Object value ) {
    if ( ( value != null ) && !this.type.isInstance( value ) ) {
        throw new IllegalArgumentException( "Unsupported value: " + value );
    }
    Object oldValue;
    PropertyChangeListener[] listeners;
    synchronized ( this.listeners ) {
        oldValue = this.value;
        this.value = value;

        if ( ( value == null ) ? oldValue == null : value.equals( oldValue ) ) {
            return; // do not fire event if value is not changed
        }
        int size = this.listeners.size();
        if ( size == 0 ) {
            return; // do not fire event if there are no any listener
        }
        listeners = this.listeners.toArray( new PropertyChangeListener[size] );
    }
    PropertyChangeEvent event = new PropertyChangeEvent( this, null, oldValue, value );
    for ( PropertyChangeListener listener : listeners ) {
        listener.propertyChange( event );
    }
}
 
Example 5
Source File: ProxyClient.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent pce) {
    PropertyChangeListener pcl = get();

    if (pcl == null) {
        // The referent listener was GC'ed, we're no longer
        // interested in PropertyChanges, remove the listener.
        dispose();
    } else {
        pcl.propertyChange(pce);
    }
}
 
Example 6
Source File: Test4234761.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    JColorChooser chooser = new JColorChooser(COLOR);
    JDialog dialog = Test4177735.show(chooser);

    PropertyChangeListener listener = new Test4234761();
    chooser.addPropertyChangeListener("color", listener); // NON-NLS: property name

    JTabbedPane tabbedPane = (JTabbedPane) chooser.getComponent(0);
    tabbedPane.setSelectedIndex(1); // HSB tab index

    if (!chooser.getColor().equals(COLOR)) {
        listener.propertyChange(null);
    }
    dialog.dispose();
}
 
Example 7
Source File: ProxyClient.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent pce) {
    PropertyChangeListener pcl = get();

    if (pcl == null) {
        // The referent listener was GC'ed, we're no longer
        // interested in PropertyChanges, remove the listener.
        dispose();
    } else {
        pcl.propertyChange(pce);
    }
}
 
Example 8
Source File: Context.java    From JsDroidCmd with Mozilla Public License 2.0 5 votes vote down vote up
private void firePropertyChangeImpl(Object listeners, String property,
                                    Object oldValue, Object newValue)
{
    for (int i = 0; ; ++i) {
        Object l = Kit.getListener(listeners, i);
        if (l == null)
            break;
        if (l instanceof PropertyChangeListener) {
            PropertyChangeListener pcl = (PropertyChangeListener)l;
            pcl.propertyChange(new PropertyChangeEvent(
                this, property, oldValue, newValue));
        }
    }
}
 
Example 9
Source File: WeakPropertyChangeSupport.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent evt) {
    PropertyChangeListener originalListener = this.listenerRef.get();
    if (originalListener != null) {
        originalListener.propertyChange(evt);
    } else {
        // the original is gone - unregister explicitly
        PropertyChangeAware source = this.sourceRef.get();
        if (source != null) {
            source.removePropertyChangeListener(this);
        }
        this.listenerRef = null;
        this.sourceRef = null;
    }
}
 
Example 10
Source File: Test4234761.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    JColorChooser chooser = new JColorChooser(COLOR);
    JDialog dialog = Test4177735.show(chooser);

    PropertyChangeListener listener = new Test4234761();
    chooser.addPropertyChangeListener("color", listener); // NON-NLS: property name

    JTabbedPane tabbedPane = (JTabbedPane) chooser.getComponent(0);
    tabbedPane.setSelectedIndex(1); // HSB tab index

    if (!chooser.getColor().equals(COLOR)) {
        listener.propertyChange(null);
    }
    dialog.dispose();
}
 
Example 11
Source File: ProxyClient.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent pce) {
    PropertyChangeListener pcl = get();

    if (pcl == null) {
        // The referent listener was GC'ed, we're no longer
        // interested in PropertyChanges, remove the listener.
        dispose();
    } else {
        pcl.propertyChange(pce);
    }
}
 
Example 12
Source File: Test4234761.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    JColorChooser chooser = new JColorChooser(COLOR);
    JDialog dialog = Test4177735.show(chooser);

    PropertyChangeListener listener = new Test4234761();
    chooser.addPropertyChangeListener("color", listener); // NON-NLS: property name

    JTabbedPane tabbedPane = (JTabbedPane) chooser.getComponent(0);
    tabbedPane.setSelectedIndex(1); // HSB tab index

    if (!chooser.getColor().equals(COLOR)) {
        listener.propertyChange(null);
    }
    dialog.dispose();
}
 
Example 13
Source File: ProxyClient.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent pce) {
    PropertyChangeListener pcl = get();

    if (pcl == null) {
        // The referent listener was GC'ed, we're no longer
        // interested in PropertyChanges, remove the listener.
        dispose();
    } else {
        pcl.propertyChange(pce);
    }
}
 
Example 14
Source File: Test4234761.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    JColorChooser chooser = new JColorChooser(COLOR);
    JDialog dialog = Test4177735.show(chooser);

    PropertyChangeListener listener = new Test4234761();
    chooser.addPropertyChangeListener("color", listener); // NON-NLS: property name

    JTabbedPane tabbedPane = (JTabbedPane) chooser.getComponent(0);
    tabbedPane.setSelectedIndex(1); // HSB tab index

    if (!chooser.getColor().equals(COLOR)) {
        listener.propertyChange(null);
    }
    dialog.dispose();
}
 
Example 15
Source File: DockingManager.java    From openAGV with Apache License 2.0 5 votes vote down vote up
/**
 * Fires a <code>PropertyChangeEvent</code> when a floatable dockable is closed
 * (eg a plugin panel).
 *
 * @param dockable The dockable that was closed.
 */
private void fireFloatingDockableClosed(DefaultSingleCDockable dockable) {
  for (PropertyChangeListener listener : listeners) {
    listener.propertyChange(
        new PropertyChangeEvent(this, DOCKABLE_CLOSED, dockable, dockable));
  }
}
 
Example 16
Source File: DockingAction.java    From ghidra with Apache License 2.0 4 votes vote down vote up
public void firePropertyChanged(String propertyName, Object oldValue, Object newValue) {
	PropertyChangeEvent event = new PropertyChangeEvent(this, propertyName, oldValue, newValue);
	for (PropertyChangeListener listener : propertyListeners) {
		listener.propertyChange(event);
	}
}
 
Example 17
Source File: ActionAdapter.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent evt) {
	for (PropertyChangeListener listener : listeners) {
		listener.propertyChange(evt);
	}
}
 
Example 18
Source File: DockingActionProxy.java    From ghidra with Apache License 2.0 4 votes vote down vote up
protected void firePropertyChanged(PropertyChangeEvent event) {
	for (PropertyChangeListener listener : propertyListeners) {
		listener.propertyChange(event);
	}
}
 
Example 19
Source File: NacosEnumEditor.java    From nacos-spring-boot-project with Apache License 2.0 4 votes vote down vote up
@Override
public void setValue(Object var1) {
	if (var1 != null && !this.type.isInstance(var1)) {
		throw new IllegalArgumentException("Unsupported value: " + var1);
	}
	else {
		Object var2;
		PropertyChangeListener[] var3;
		synchronized (this.listeners) {
			label45: {
				var2 = this.value;
				this.value = var1;
				if (var1 == null) {
					if (var2 != null) {
						break label45;
					}
				}
				else if (!var1.equals(var2)) {
					break label45;
				}

				return;
			}

			int var5 = this.listeners.size();
			if (var5 == 0) {
				return;
			}

			var3 = (PropertyChangeListener[]) this.listeners
					.toArray(new PropertyChangeListener[var5]);
		}

		PropertyChangeEvent var4 = new PropertyChangeEvent(this, (String) null, var2,
				var1);
		PropertyChangeListener[] var10 = var3;
		int var6 = var3.length;

		for (int var7 = 0; var7 < var6; ++var7) {
			PropertyChangeListener var8 = var10[var7];
			var8.propertyChange(var4);
		}

	}
}
 
Example 20
Source File: WidgetUtilities.java    From radiance with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Fires the matching property change event on the specific component.
 * 
 * @param component
 *            Component.
 * @param propertyName
 *            Property name.
 * @param oldValue
 *            Old property value.
 * @param newValue
 *            New property value.
 */
public static void firePropertyChangeEvent(JComponent component, String propertyName,
        Object oldValue, Object newValue) {
    PropertyChangeEvent pce = new PropertyChangeEvent(component, propertyName, oldValue,
            newValue);
    for (PropertyChangeListener general : component.getPropertyChangeListeners()) {
        general.propertyChange(pce);
    }
    for (PropertyChangeListener specific : component.getPropertyChangeListeners(propertyName)) {
        specific.propertyChange(pce);
    }
}