Class ToggleActionPropertyChangeListener

java.lang.Object
org.jdesktop.swingx.action.ToggleActionPropertyChangeListener
All Implemented Interfaces:
PropertyChangeListener, EventListener

class ToggleActionPropertyChangeListener extends Object implements PropertyChangeListener
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 Details

  • Constructor Details

    • ToggleActionPropertyChangeListener

      public ToggleActionPropertyChangeListener(Action action, AbstractButton button)
  • Method Details

    • shouldAddListener

      protected boolean shouldAddListener(Action action, AbstractButton button)
    • isToggling

      protected boolean isToggling(Action action, AbstractButton button)
    • releasePCLs

      protected void releasePCLs(Action action)
      Removes all ToggleActionPCLs with unreachable target buttons from the Action's PCL-listeners.
      Parameters:
      action - to cleanup.
    • propertyChange

      public void propertyChange(PropertyChangeEvent evt)
      Specified by:
      propertyChange in interface PropertyChangeListener
    • checkReferent

      protected AbstractButton checkReferent(Action action)
      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

      public boolean isToggling(AbstractButton button)
      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.