java.lang.Object
org.controlsfx.control.action.Action
- All Implemented Interfaces:
EventListener,EventHandler<ActionEvent>
- Direct Known Subclasses:
ActionGroup,AnnotatedAction,ColumnFixAction,ListActionView.ListAction,ListSelectionView.ListSelectionAction,RowFixAction
A base class for Action API.
What is an Action?
An action in JavaFX can be used to separate functionality and state from a control. For example, if you have two or more controls that perform the same function (e.g. one in aMenu and another on a toolbar), consider
using an Action object to implement the function. An Action object provides
centralized handling of the state of action-event-firing components such as
buttons, menu items, etc. The state that an action can handle includes text,
graphic, long text (i.e. tooltip text), and disabled.-
Property Summary
PropertiesTypePropertyDescriptionfinal ObjectProperty<KeyCombination>The acceleratorKeyCombinationthat should be used for this action, if it is used in an applicable UI control (most notablyMenuItem).final BooleanPropertyThis represents whether the action should be available to the end user, or whether it should appeared 'grayed out'.final ObjectProperty<Node>The graphic that should be shown to the user in relation to this action.final StringPropertyThe longer form of the text to show to the user (e.g.final BooleanPropertyRepresents action's selected state.final StringPropertyA string representation of the CSS style associated with this Action instance and passed to related UI controls.final StringPropertyThe text to show to the user. -
Constructor Summary
ConstructorsConstructorDescriptionConstructorsAction(String text, Consumer<ActionEvent> eventHandler) Creates a new AbstractAction instance with the given String set as thetextvalue, as well as theConsumer<ActionEvent>set to be called when the action event is fired.Action(Consumer<ActionEvent> eventHandler) -
Method Summary
Modifier and TypeMethodDescriptionfinal ObjectProperty<KeyCombination>The acceleratorKeyCombinationthat should be used for this action, if it is used in an applicable UI control (most notablyMenuItem).final BooleanPropertyThis represents whether the action should be available to the end user, or whether it should appeared 'grayed out'.final KeyCombinationprotected Consumer<ActionEvent>final Nodefinal Stringfinal ObservableMap<Object,Object> Returns an observable map of properties on this Action for use primarily by application developers.final StringgetStyle()Gets the value of the property style.A list of String identifiers which can be used to logically group Nodes, specifically for an external style engine.final StringgetText()final ObjectProperty<Node>The graphic that should be shown to the user in relation to this action.final voidhandle(ActionEvent event) Defers to theConsumer<ActionEvent>passed in to the Action constructor.final booleanfinal booleanSelected state of the Action.protected voidlock()final StringPropertyThe longer form of the text to show to the user (e.g.final BooleanPropertyRepresents action's selected state.final voidsetAccelerator(KeyCombination value) Sets the acceleratorKeyCombinationthat should be used for this action, if it is used in an applicable UI controlfinal voidsetDisabled(boolean value) Sets whether the action should be available to the end user, or whether it should appeared 'grayed out'.protected voidsetEventHandler(Consumer<ActionEvent> eventHandler) final voidsetGraphic(Node value) Sets the graphic that should be shown to the user in relation to this action.final voidsetLongText(String value) Sets the longer form of the text to show to the userfinal voidsetSelected(boolean selected) Sets selected state of the Actionfinal voidSets the value of the property style.final voidSets the text of the Action.final StringPropertyA string representation of the CSS style associated with this Action instance and passed to related UI controls.final StringPropertyThe text to show to the user.
-
Property Details
-
style
A string representation of the CSS style associated with this Action instance and passed to related UI controls. This is analogous to the "style" attribute of an HTML element. Note that, like the HTML style attribute, this variable contains style properties and values and not the selector portion of a style rule.Parsing this style might not be supported on some limited platforms. It is recommended to use a standalone CSS file instead.
- See Also:
-
selected
Represents action's selected state. Usually bound to selected state of components such as Toggle Buttons, CheckBOxes etc- See Also:
-
text
The text to show to the user.- See Also:
-
disabled
This represents whether the action should be available to the end user, or whether it should appeared 'grayed out'.- See Also:
-
longText
The longer form of the text to show to the user (e.g. on aButton, it is usually a tooltip that should be shown to the user if their mouse hovers over this action).- See Also:
-
graphic
The graphic that should be shown to the user in relation to this action.- See Also:
-
accelerator
The acceleratorKeyCombinationthat should be used for this action, if it is used in an applicable UI control (most notablyMenuItem).
-
-
Constructor Details
-
Action
Constructors -
Action
-
Action
Creates a new AbstractAction instance with the given String set as thetextvalue, as well as theConsumer<ActionEvent>set to be called when the action event is fired.- Parameters:
text- The string to display in the text property of controls such asButton.eventHandler- This will be called when the ActionEvent is fired.
-
-
Method Details
-
lock
protected void lock() -
setStyle
Sets the value of the property style.- Property description:
- A string representation of the CSS style associated with this
Action instance and passed to related UI controls.
This is analogous to the "style" attribute of an
HTML element. Note that, like the HTML style attribute, this
variable contains style properties and values and not the
selector portion of a style rule.
Parsing this style might not be supported on some limited platforms. It is recommended to use a standalone CSS file instead.
-
getStyle
Gets the value of the property style.- Property description:
- A string representation of the CSS style associated with this
Action instance and passed to related UI controls.
This is analogous to the "style" attribute of an
HTML element. Note that, like the HTML style attribute, this
variable contains style properties and values and not the
selector portion of a style rule.
Parsing this style might not be supported on some limited platforms. It is recommended to use a standalone CSS file instead.
-
styleProperty
A string representation of the CSS style associated with this Action instance and passed to related UI controls. This is analogous to the "style" attribute of an HTML element. Note that, like the HTML style attribute, this variable contains style properties and values and not the selector portion of a style rule.Parsing this style might not be supported on some limited platforms. It is recommended to use a standalone CSS file instead.
- See Also:
-
getStyleClass
A list of String identifiers which can be used to logically group Nodes, specifically for an external style engine. This variable is analogous to the "class" attribute on an HTML element and, as such, each element of the list is a style class to which this Node belongs.- See Also:
-
selectedProperty
Represents action's selected state. Usually bound to selected state of components such as Toggle Buttons, CheckBOxes etc- See Also:
-
isSelected
public final boolean isSelected()Selected state of the Action.- Returns:
- The selected state of this action.
-
setSelected
public final void setSelected(boolean selected) Sets selected state of the Action- Parameters:
selected-
-
textProperty
The text to show to the user.- See Also:
-
getText
- Returns:
- the text of the Action.
-
setText
Sets the text of the Action.- Parameters:
value-
-
disabledProperty
This represents whether the action should be available to the end user, or whether it should appeared 'grayed out'.- See Also:
-
isDisabled
public final boolean isDisabled()- Returns:
- whether the action is available to the end user, or whether it should appeared 'grayed out'.
-
setDisabled
public final void setDisabled(boolean value) Sets whether the action should be available to the end user, or whether it should appeared 'grayed out'.- Parameters:
value-
-
longTextProperty
The longer form of the text to show to the user (e.g. on aButton, it is usually a tooltip that should be shown to the user if their mouse hovers over this action).- See Also:
-
getLongText
- Returns:
- The longer form of the text to show to the user
- See Also:
-
setLongText
Sets the longer form of the text to show to the user- Parameters:
value-- See Also:
-
graphicProperty
The graphic that should be shown to the user in relation to this action.- See Also:
-
getGraphic
- Returns:
- The graphic that should be shown to the user in relation to this action.
-
setGraphic
Sets the graphic that should be shown to the user in relation to this action.- Parameters:
value-
-
acceleratorProperty
The acceleratorKeyCombinationthat should be used for this action, if it is used in an applicable UI control (most notablyMenuItem). -
getAccelerator
- Returns:
- The accelerator
KeyCombinationthat should be used for this action, if it is used in an applicable UI control
-
setAccelerator
Sets the acceleratorKeyCombinationthat should be used for this action, if it is used in an applicable UI control- Parameters:
value-
-
getProperties
Returns an observable map of properties on this Action for use primarily by application developers.- Returns:
- An observable map of properties on this Action for use primarily by application developers
-
getEventHandler
-
setEventHandler
-
handle
Defers to theConsumer<ActionEvent>passed in to the Action constructor.- Specified by:
handlein interfaceEventHandler<ActionEvent>
-