java.lang.Object
org.controlsfx.control.action.Action
- All Implemented Interfaces:
EventListener
,javafx.event.EventHandler<javafx.event.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 javafx.beans.property.ObjectProperty
<javafx.scene.input.KeyCombination> The acceleratorKeyCombination
that should be used for this action, if it is used in an applicable UI control (most notablyMenuItem
).final javafx.beans.property.BooleanProperty
This represents whether the action should be available to the end user, or whether it should appeared 'grayed out'.final javafx.beans.property.ObjectProperty
<javafx.scene.Node> The graphic that should be shown to the user in relation to this action.final javafx.beans.property.StringProperty
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).final javafx.beans.property.BooleanProperty
Represents action's selected state.final javafx.beans.property.StringProperty
A string representation of the CSS style associated with this Action instance and passed to related UI controls.final javafx.beans.property.StringProperty
The text to show to the user. -
Constructor Summary
ConstructorsConstructorDescriptionConstructorsCreates a new AbstractAction instance with the given String set as thetext
value, as well as theConsumer<ActionEvent>
set to be called when the action event is fired. -
Method Summary
Modifier and TypeMethodDescriptionfinal javafx.beans.property.ObjectProperty
<javafx.scene.input.KeyCombination> The acceleratorKeyCombination
that should be used for this action, if it is used in an applicable UI control (most notablyMenuItem
).final javafx.beans.property.BooleanProperty
This represents whether the action should be available to the end user, or whether it should appeared 'grayed out'.final javafx.scene.input.KeyCombination
protected Consumer
<javafx.event.ActionEvent> final javafx.scene.Node
final String
Returns an observable map of properties on this Action for use primarily by application developers.final String
getStyle()
Gets the value of thestyle
property.javafx.collections.ObservableList
<String> A list of String identifiers which can be used to logically group Nodes, specifically for an external style engine.final String
getText()
final javafx.beans.property.ObjectProperty
<javafx.scene.Node> The graphic that should be shown to the user in relation to this action.final void
handle
(javafx.event.ActionEvent event) Defers to theConsumer<ActionEvent>
passed in to the Action constructor.final boolean
final boolean
Selected state of the Action.protected void
lock()
final javafx.beans.property.StringProperty
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).final javafx.beans.property.BooleanProperty
Represents action's selected state.final void
setAccelerator
(javafx.scene.input.KeyCombination value) Sets the acceleratorKeyCombination
that should be used for this action, if it is used in an applicable UI controlfinal void
setDisabled
(boolean value) Sets whether the action should be available to the end user, or whether it should appeared 'grayed out'.protected void
setEventHandler
(Consumer<javafx.event.ActionEvent> eventHandler) final void
setGraphic
(javafx.scene.Node value) Sets the graphic that should be shown to the user in relation to this action.final void
setLongText
(String value) Sets the longer form of the text to show to the userfinal void
setSelected
(boolean selected) Sets selected state of the Actionfinal void
Sets the value of thestyle
property.final void
Sets the text of the Action.final javafx.beans.property.StringProperty
A string representation of the CSS style associated with this Action instance and passed to related UI controls.final javafx.beans.property.StringProperty
The text to show to the user.
-
Property Details
-
style
public final javafx.beans.property.StringProperty stylePropertyA 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
public final javafx.beans.property.BooleanProperty selectedPropertyRepresents action's selected state. Usually bound to selected state of components such as Toggle Buttons, CheckBOxes etc- See Also:
-
text
public final javafx.beans.property.StringProperty textPropertyThe text to show to the user.- See Also:
-
disabled
public final javafx.beans.property.BooleanProperty disabledPropertyThis represents whether the action should be available to the end user, or whether it should appeared 'grayed out'.- See Also:
-
longText
public final javafx.beans.property.StringProperty longTextPropertyThe 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
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> graphicPropertyThe graphic that should be shown to the user in relation to this action.- See Also:
-
accelerator
public final javafx.beans.property.ObjectProperty<javafx.scene.input.KeyCombination> acceleratorPropertyThe acceleratorKeyCombination
that should be used for this action, if it is used in an applicable UI control (most notablyMenuItem
).- See Also:
-
-
Constructor Details
-
Action
Constructors -
Action
-
Action
Creates a new AbstractAction instance with the given String set as thetext
value, 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 thestyle
property.- 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.
- Parameters:
value
- the value for thestyle
property- See Also:
-
getStyle
Gets the value of thestyle
property.- 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.
- Returns:
- the value of the
style
property - See Also:
-
styleProperty
public final javafx.beans.property.StringProperty 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.
- Returns:
- the
style
property - 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
public final javafx.beans.property.BooleanProperty selectedProperty()Represents action's selected state. Usually bound to selected state of components such as Toggle Buttons, CheckBOxes etc- Returns:
- An observable
BooleanProperty
that represents the current selected state, and which can be observed for changes. - 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
public final javafx.beans.property.StringProperty textProperty()The text to show to the user.- Returns:
- An observable
StringProperty
that represents the current text for this property, and which can be observed for changes. - See Also:
-
getText
- Returns:
- the text of the Action.
-
setText
Sets the text of the Action.- Parameters:
value
-
-
disabledProperty
public final javafx.beans.property.BooleanProperty disabledProperty()This represents whether the action should be available to the end user, or whether it should appeared 'grayed out'.- Returns:
- An observable
BooleanProperty
that represents the current disabled state for this property, and which can be observed for changes. - 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
public final javafx.beans.property.StringProperty 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).- Returns:
- An observable
StringProperty
that represents the current long text for this property, and which can be observed for changes. - 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
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> graphicProperty()The graphic that should be shown to the user in relation to this action.- Returns:
- An observable
ObjectProperty
that represents the current graphic for this property, and which can be observed for changes. - See Also:
-
getGraphic
public final javafx.scene.Node getGraphic()- Returns:
- The graphic that should be shown to the user in relation to this action.
-
setGraphic
public final void setGraphic(javafx.scene.Node value) Sets the graphic that should be shown to the user in relation to this action.- Parameters:
value
-
-
acceleratorProperty
public final javafx.beans.property.ObjectProperty<javafx.scene.input.KeyCombination> acceleratorProperty()The acceleratorKeyCombination
that should be used for this action, if it is used in an applicable UI control (most notablyMenuItem
).- Returns:
- An observable
ObjectProperty
that represents the current accelerator for this property, and which can be observed for changes. - See Also:
-
getAccelerator
public final javafx.scene.input.KeyCombination getAccelerator()- Returns:
- The accelerator
KeyCombination
that should be used for this action, if it is used in an applicable UI control
-
setAccelerator
public final void setAccelerator(javafx.scene.input.KeyCombination value) Sets the acceleratorKeyCombination
that 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
public final void handle(javafx.event.ActionEvent event) Defers to theConsumer<ActionEvent>
passed in to the Action constructor.- Specified by:
handle
in interfacejavafx.event.EventHandler<javafx.event.ActionEvent>
-