Package org.jdesktop.swingx.action
Class ToggleActionPropertyChangeListener
java.lang.Object
org.jdesktop.swingx.action.ToggleActionPropertyChangeListener
- All Implemented Interfaces:
PropertyChangeListener
,EventListener
Added to the Toggle type buttons and menu items so that various components
which have been created from a single StateChangeAction can be in synch.
This listener is responsible for updating the selected property from the
Action to the AbstractButton.
It guarantees a maximum of 1 instance of ToggleActionPCL to be installed per button (PENDING JW: add test to verify). It removes all ToggleActionPCLs which are targeted to unreachable buttons from the action's listener list.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected AbstractButton
checkReferent
(Action action) Returns the target button to synchronize from the listener.boolean
isToggling
(AbstractButton button) Check if this is already synchronizing the given AbstractButton.protected boolean
isToggling
(Action action, AbstractButton button) void
protected void
releasePCLs
(Action action) Removes all ToggleActionPCLs with unreachable target buttons from the Action's PCL-listeners.protected boolean
shouldAddListener
(Action action, AbstractButton button)
-
Field Details
-
buttonRef
-
-
Constructor Details
-
ToggleActionPropertyChangeListener
-
-
Method Details
-
shouldAddListener
-
isToggling
-
releasePCLs
Removes all ToggleActionPCLs with unreachable target buttons from the Action's PCL-listeners.- Parameters:
action
- to cleanup.
-
propertyChange
- Specified by:
propertyChange
in interfacePropertyChangeListener
-
checkReferent
Returns the target button to synchronize from the listener. Side-effects if the target is no longer reachable: - the internal reference to target is nulled. - if the given action is != null, this listener removes itself from the action's listener list.- Parameters:
action
- The action this is listening to.- Returns:
- the target button if it is strongly reachable or null if it is no longer strongly reachable.
-
isToggling
Check if this is already synchronizing the given AbstractButton. This may have the side-effect of releasing the weak reference to the target button.- Parameters:
button
- must not be null- Returns:
- true if this target button and the given comp are equal false otherwise.
- Throws:
NullPointerException
- if the button is null.
-