Methods Summary |
---|
protected abstract void | actionPropertyChanged(T target, javax.swing.Action action, java.beans.PropertyChangeEvent e)Invoked when a property changes on the Action and the target
still exists.
|
public javax.swing.Action | getAction()
return action;
|
private static java.lang.ref.ReferenceQueue | getQueue()
synchronized(ActionPropertyChangeListener.class) {
if (queue == null) {
queue = new ReferenceQueue<JComponent>();
}
}
return queue;
|
public T | getTarget()
if (target == null) {
// Will only happen if serialized and real target was null
return null;
}
return this.target.get();
|
public final void | propertyChange(java.beans.PropertyChangeEvent e)PropertyChangeListener method. If the target has been gc'ed this
will remove the PropertyChangeListener from the Action,
otherwise this will invoke actionPropertyChanged.
T target = getTarget();
if (target == null) {
getAction().removePropertyChangeListener(this);
} else {
actionPropertyChanged(target, getAction(), e);
}
|
private void | readObject(java.io.ObjectInputStream s)
s.defaultReadObject();
T target = (T)s.readObject();
if (target != null) {
setTarget(target);
}
|
private void | setTarget(T c)
ReferenceQueue<JComponent> queue = getQueue();
// Check to see whether any old buttons have
// been enqueued for GC. If so, look up their
// PCL instance and remove it from its Action.
OwnedWeakReference r;
while ((r = (OwnedWeakReference)queue.poll()) != null) {
ActionPropertyChangeListener oldPCL = r.getOwner();
Action oldAction = oldPCL.getAction();
if (oldAction!=null) {
oldAction.removePropertyChangeListener(oldPCL);
}
}
this.target = new OwnedWeakReference<T>(c, queue, this);
|
private void | writeObject(java.io.ObjectOutputStream s)
s.defaultWriteObject();
s.writeObject(getTarget());
|