FileDocCategorySizeDatePackage
SwingPropertyChangeSupport.javaAPI DocJava SE 6 API3203Tue Jun 10 00:26:44 BST 2008javax.swing.event

SwingPropertyChangeSupport

public final class SwingPropertyChangeSupport extends PropertyChangeSupport
This subclass of {@code java.beans.PropertyChangeSupport} is almost identical in functionality. The only difference is if constructed with {@code SwingPropertyChangeSupport(sourceBean, true)} it ensures listeners are only ever notified on the Event Dispatch Thread.
version
1.23 02/14/06
author
Igor Kushnirskiy

Fields Summary
static final long
serialVersionUID
private final boolean
notifyOnEDT
whether to notify listeners on EDT
Constructors Summary
public SwingPropertyChangeSupport(Object sourceBean)
Constructs a SwingPropertyChangeSupport object.

param
sourceBean The bean to be given as the source for any events.
throws
NullPointerException if {@code sourceBean} is {@code null}

        this(sourceBean, false);
    
public SwingPropertyChangeSupport(Object sourceBean, boolean notifyOnEDT)
Constructs a SwingPropertyChangeSupport object.

param
sourceBean the bean to be given as the source for any events
param
notifyOnEDT whether to notify listeners on the Event Dispatch Thread only
throws
NullPointerException if {@code sourceBean} is {@code null}
since
1.6

        super(sourceBean);
        this.notifyOnEDT = notifyOnEDT;
    
Methods Summary
public voidfirePropertyChange(java.beans.PropertyChangeEvent evt)
{@inheritDoc}

If {@link #isNotifyOnEDT} is {@code true} and called off the Event Dispatch Thread this implementation uses {@code SwingUtilities.invokeLater} to send out the notification on the Event Dispatch Thread. This ensures listeners are only ever notified on the Event Dispatch Thread.

throws
NullPointerException if {@code evt} is {@code null}
since
1.6

        if (evt == null) {
            throw new NullPointerException();
        }
        if (! isNotifyOnEDT()
            || SwingUtilities.isEventDispatchThread()) {
            super.firePropertyChange(evt);
        } else {
            SwingUtilities.invokeLater(
                new Runnable() {
                    public void run() {
                        firePropertyChange(evt);
                    }
                });
        }
    
public final booleanisNotifyOnEDT()
Returns {@code notifyOnEDT} property.

return
{@code notifyOnEDT} property
see
#SwingPropertyChangeSupport(Object sourceBean, boolean notifyOnEDT)
since
1.6

        return notifyOnEDT;