- java.lang.Object
-
- org.controlsfx.control.action.Action
-
- org.controlsfx.control.action.AnnotatedAction
-
- All Implemented Interfaces:
EventListener
,EventHandler<ActionEvent>
- Direct Known Subclasses:
AnnotatedCheckAction
public class AnnotatedAction extends Action
An action that invokes a method that has been annotated withActionProxy
. These actions are created viaActionMap.register(java.lang.Object)
, which delegates the actual instantiation to anAnnotatedActionFactory
. 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 Summary
Constructors Constructor Description AnnotatedAction(String text, Method method, Object target)
Instantiates an action that will call the specified method on the specified target.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
getTarget()
Returns the target object (the object on which the annotated method will be called).protected void
handleAction(ActionEvent ae)
Handle the action-event by invoking the annotated method on the target object.protected void
handleActionException(ActionEvent ae, Throwable ex)
Called if the annotated method throws an exception when invoked.String
toString()
Overridden to return the text of this action.-
Methods inherited from class org.controlsfx.control.action.Action
acceleratorProperty, disabledProperty, getAccelerator, getEventHandler, getGraphic, getLongText, getProperties, getStyle, getStyleClass, getText, graphicProperty, handle, isDisabled, isSelected, lock, longTextProperty, selectedProperty, setAccelerator, setDisabled, setEventHandler, setGraphic, setLongText, setSelected, setStyle, setText, styleProperty, textProperty
-
-
-
-
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(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(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.
-
-