Top Description Fields Constructors Methods
org.controlsfx.control.action

public Class Action

extends Object
implements EventHandler<ActionEvent>
Class Inheritance
All Implemented Interfaces
javafx.event.EventHandler, java.util.EventListener
Known Direct Subclasses
org.controlsfx.control.action.ActionGroup, org.controlsfx.control.action.AnnotatedAction, org.controlsfx.control.tableview2.actions.ColumnFixAction, org.controlsfx.control.tableview2.actions.RowFixAction, impl.org.controlsfx.skin.PropertySheetSkin.ActionChangeMode, org.controlsfx.control.ListActionView.ListAction, org.controlsfx.control.ListSelectionView.ListSelectionAction
Imports
impl.org.controlsfx.i18n.Localization, .SimpleLocalizedStringProperty, java.util.function.Consumer, javafx.beans.NamedArg, javafx.beans.property.BooleanProperty, .ObjectProperty, .SimpleBooleanProperty, .SimpleObjectProperty, .SimpleStringProperty, .StringProperty, javafx.collections.FXCollections, .ObservableList, .ObservableMap, javafx.event.ActionEvent, .EventHandler, javafx.scene.Node, javafx.scene.control.Button, .Menu, .MenuItem, javafx.scene.input.KeyCombination

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 a Menu 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.

Field Summary

Modifier and TypeField and Description
private final ObjectProperty<KeyCombination>
private final BooleanProperty
private Consumer<ActionEvent>
private final ObjectProperty<Node>
private boolean
locked

Private fields

private final StringProperty
private ObservableMap<Object, Object>
private final BooleanProperty
private StringProperty
style

A string representation of the CSS style associated with this Action instance and passed to related UI controls.

private final ObservableList<String>
private final StringProperty

Constructor Summary

AccessConstructor and Description
public
Action(String text)

Constructors

public
Action(Consumer<ActionEvent> eventHandler)

public
Action(String
The string to display in the text property of controls such as Button.
text
,
Consumer<ActionEvent>
This will be called when the ActionEvent is fired.
eventHandler
)

Creates a new AbstractAction instance with the given String set as the text value, as well as the Consumer<ActionEvent> set to be called when the action event is fired.

Method Summary

Modifier and TypeMethod and Description
public final ObjectProperty<KeyCombination>

Returns:

An observable ObjectProperty that represents the current accelerator for this property, and which can be observed for changes.
acceleratorProperty
()

The accelerator KeyCombination that should be used for this action, if it is used in an applicable UI control (most notably MenuItem).

public final BooleanProperty

Returns:

An observable BooleanProperty that represents the current disabled state for this property, and which can be observed for changes.
disabledProperty
()

This represents whether the action should be available to the end user, or whether it should appeared 'grayed out'.

public final KeyCombination
getAccelerator()

Returns: The accelerator KeyCombination that should be used for this action, if it is used in an applicable UI control

protected Consumer<ActionEvent>
public final Node
getGraphic()

Returns: The graphic that should be shown to the user in relation to this action.

public final String
getLongText()

Returns: The longer form of the text to show to the user

public final synchronized ObservableMap<Object, Object>

Returns:

An observable map of properties on this Action for use primarily by application developers
getProperties
()

Returns an observable map of properties on this Action for use primarily by application developers.

public final String
public ObservableList<String>
getStyleClass()

A list of String identifiers which can be used to logically group Nodes, specifically for an external style engine.

public final String
getText()

Returns: the text of the Action.

public final ObjectProperty<Node>

Returns:

An observable ObjectProperty that represents the current graphic for this property, and which can be observed for changes.
graphicProperty
()

The graphic that should be shown to the user in relation to this action.

public final void
handle(ActionEvent event)

Implements javafx.event.EventHandler.handle.

Defers to the Consumer<ActionEvent> passed in to the Action constructor.

public final boolean
isDisabled()

Returns: whether the action is available to the end user, or whether it should appeared 'grayed out'.

public final boolean

Returns:

The selected state of this action.
isSelected
()

Selected state of the Action.

protected void
lock()

public final StringProperty

Returns:

An observable StringProperty that represents the current long text for this property, and which can be observed for changes.
longTextProperty
()

The longer form of the text to show to the user (e.g. on a Button, it is usually a tooltip that should be shown to the user if their mouse hovers over this action).

public final BooleanProperty

Returns:

An observable BooleanProperty that represents the current selected state, and which can be observed for changes.
selectedProperty
()

Represents action's selected state.

public final void
setAccelerator(KeyCombination value)

Sets the accelerator KeyCombination that should be used for this action, if it is used in an applicable UI control

public final void
setDisabled(boolean value)

Sets whether the action should be available to the end user, or whether it should appeared 'grayed out'.

protected void
public final void
setGraphic(Node value)

Sets the graphic that should be shown to the user in relation to this action.

public final void
setLongText(String value)

Sets the longer form of the text to show to the user

public final void
setSelected(boolean selected)

Sets selected state of the Action

public final void
public final void
setText(String value)

Sets the text of the Action.

public final StringProperty
public final StringProperty

Returns:

An observable StringProperty that represents the current text for this property, and which can be observed for changes.
textProperty
()

The text to show to the user.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

acceleratorPropertyback to summary
private final ObjectProperty<KeyCombination> acceleratorProperty
disabledPropertyback to summary
private final BooleanProperty disabledProperty
eventHandlerback to summary
private Consumer<ActionEvent> eventHandler
graphicPropertyback to summary
private final ObjectProperty<Node> graphicProperty
lockedback to summary
private boolean locked

Private fields

longTextPropertyback to summary
private final StringProperty longTextProperty
propsback to summary
private ObservableMap<Object, Object> props
selectedPropertyback to summary
private final BooleanProperty selectedProperty
styleback to summary
private StringProperty 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.

styleClassback to summary
private final ObservableList<String> styleClass
textPropertyback to summary
private final StringProperty textProperty

Constructor Detail

Actionback to summary
public Action(String text)

Constructors

Actionback to summary
public Action(Consumer<ActionEvent> eventHandler)
Actionback to summary
public Action(String text, Consumer<ActionEvent> eventHandler)

Creates a new AbstractAction instance with the given String set as the text value, as well as the Consumer<ActionEvent> set to be called when the action event is fired.

Parameters
text:String

The string to display in the text property of controls such as Button.

eventHandler:Consumer<ActionEvent>

This will be called when the ActionEvent is fired.

Method Detail

acceleratorPropertyback to summary
public final ObjectProperty<KeyCombination> acceleratorProperty()

The accelerator KeyCombination that should be used for this action, if it is used in an applicable UI control (most notably MenuItem).

Returns:ObjectProperty<KeyCombination>

An observable ObjectProperty that represents the current accelerator for this property, and which can be observed for changes.

disabledPropertyback to summary
public final BooleanProperty disabledProperty()

This represents whether the action should be available to the end user, or whether it should appeared 'grayed out'.

Returns:BooleanProperty

An observable BooleanProperty that represents the current disabled state for this property, and which can be observed for changes.

getAcceleratorback to summary
public final KeyCombination getAccelerator()
Returns:KeyCombination

The accelerator KeyCombination that should be used for this action, if it is used in an applicable UI control

getEventHandlerback to summary
protected Consumer<ActionEvent> getEventHandler()
getGraphicback to summary
public final Node getGraphic()
Returns:Node

The graphic that should be shown to the user in relation to this action.

getLongTextback to summary
public final String getLongText()
Returns:String

The longer form of the text to show to the user

See Also
longTextProperty()
getPropertiesback to summary
public final synchronized ObservableMap<Object, Object> getProperties()

Returns an observable map of properties on this Action for use primarily by application developers.

Returns:ObservableMap<Object, Object>

An observable map of properties on this Action for use primarily by application developers

getStyleback to summary
public final String getStyle()
getStyleClassback to summary
public ObservableList<String> 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
CSS3 class selectors
getTextback to summary
public final String getText()
Returns:String

the text of the Action.

graphicPropertyback to summary
public final ObjectProperty<Node> graphicProperty()

The graphic that should be shown to the user in relation to this action.

Returns:ObjectProperty<Node>

An observable ObjectProperty that represents the current graphic for this property, and which can be observed for changes.

handleback to summary
public final void handle(ActionEvent event)

Implements javafx.event.EventHandler.handle.

Defers to the Consumer<ActionEvent> passed in to the Action constructor.

Annotations
@Override
isDisabledback to summary
public final boolean isDisabled()
Returns:boolean

whether the action is available to the end user, or whether it should appeared 'grayed out'.

isSelectedback to summary
public final boolean isSelected()

Selected state of the Action.

Returns:boolean

The selected state of this action.

lockback to summary
protected void lock()
longTextPropertyback to summary
public final StringProperty longTextProperty()

The longer form of the text to show to the user (e.g. on a Button, it is usually a tooltip that should be shown to the user if their mouse hovers over this action).

Returns:StringProperty

An observable StringProperty that represents the current long text for this property, and which can be observed for changes.

selectedPropertyback to summary
public final BooleanProperty selectedProperty()

Represents action's selected state. Usually bound to selected state of components such as Toggle Buttons, CheckBOxes etc

Returns:BooleanProperty

An observable BooleanProperty that represents the current selected state, and which can be observed for changes.

setAcceleratorback to summary
public final void setAccelerator(KeyCombination value)

Sets the accelerator KeyCombination that should be used for this action, if it is used in an applicable UI control

setDisabledback to summary
public final void setDisabled(boolean value)

Sets whether the action should be available to the end user, or whether it should appeared 'grayed out'.

setEventHandlerback to summary
protected void setEventHandler(Consumer<ActionEvent> eventHandler)
setGraphicback to summary
public final void setGraphic(Node value)

Sets the graphic that should be shown to the user in relation to this action.

setLongTextback to summary
public final void setLongText(String value)

Sets the longer form of the text to show to the user

See Also
longTextProperty()
setSelectedback to summary
public final void setSelected(boolean selected)

Sets selected state of the Action

setStyleback to summary
public final void setStyle(String value)
setTextback to summary
public final void setText(String value)

Sets the text of the Action.

stylePropertyback to summary
public final StringProperty styleProperty()
textPropertyback to summary
public final StringProperty textProperty()

The text to show to the user.

Returns:StringProperty

An observable StringProperty that represents the current text for this property, and which can be observed for changes.