Class AnnotatedAction

  • All Implemented Interfaces:
    EventListener, javafx.event.EventHandler<javafx.event.ActionEvent>
    Direct Known Subclasses:
    AnnotatedCheckAction

    public class AnnotatedAction
    extends Action
    An action that invokes a method that has been annotated with ActionProxy. These actions are created via ActionMap.register(java.lang.Object), which delegates the actual instantiation to an AnnotatedActionFactory. Note that this class maintains a WeakReference to the supplied target object, so the existence of an AnnotatedAction instance will not prevent the target from being garbage-collected.
    • Constructor Detail

      • AnnotatedAction

        public AnnotatedAction​(String text,
                               Method method,
                               Object target)
        Instantiates an action that will call the specified method on the specified target.
    • Method Detail

      • getTarget

        public Object getTarget()
        Returns the target object (the object on which the annotated method will be called).
        Returns:
        The target object, or null if the target object has been garbage-collected.
      • handleAction

        protected void handleAction​(javafx.event.ActionEvent ae)
        Handle the action-event by invoking the annotated method on the target object. If an exception is thrown, then the default implementation of this method will call handleActionException().
      • handleActionException

        protected void handleActionException​(javafx.event.ActionEvent ae,
                                             Throwable ex)
        Called if the annotated method throws an exception when invoked. The default implementation of this method simply prints the stack trace of the specified exception.
      • toString

        public String toString()
        Overridden to return the text of this action.
        Overrides:
        toString in class Object