Top Description Fields Constructors Methods
javafx.scene.control

public abstract Class ButtonBase

extends Labeled
Class Inheritance
Known Direct Subclasses
javafx.scene.control.CheckBox, javafx.scene.control.Hyperlink, javafx.scene.control.MenuButton, javafx.scene.control.ToggleButton, javafx.scene.control.Button
Imports
javafx.css.PseudoClass, javafx.beans.property.ObjectProperty, .ObjectPropertyBase, .ReadOnlyBooleanProperty, .ReadOnlyBooleanWrapper, javafx.event.ActionEvent, .EventHandler, javafx.scene.AccessibleAction, .Node

Base class for button-like UI Controls, including Hyperlinks, Buttons, ToggleButtons, CheckBoxes, and RadioButtons. The primary contribution of ButtonBase is providing a consistent API for handling the concept of button "arming". In UIs, a button will typically only "fire" if some user gesture occurs while the button is "armed". For example, a Button may be armed if the mouse is pressed and the Button is enabled and the mouse is over the button. In such a situation, if the mouse is then released, then the Button is "fired", meaning its action takes place.
Since
JavaFX 2.0

Field Summary

Modifier and TypeField and Description
private ReadOnlyBooleanWrapper
private static final PseudoClass
private ObjectProperty<EventHandler<ActionEvent>>

Constructor Summary

AccessConstructor and Description
public
ButtonBase()

Create a default ButtonBase with empty text.

public
ButtonBase(String
null text is treated as the empty string
text
)

Create a ButtonBase with the given text.

public
ButtonBase(String
null text is treated as the empty string
text
,
Node
a null graphic is acceptable
graphic
)

Create a ButtonBase with the given text and graphic.

Method Summary

Modifier and TypeMethod and Description
public void
arm()

Arms the button.

public final ReadOnlyBooleanProperty

Returns:

the property to indicate that the button has been "armed"
armedProperty
()

Indicates that the button has been "armed" such that a mouse release will cause the button's action to be invoked.

public void
disarm()

Disarms the button.

public void
executeAccessibleAction(AccessibleAction action, Object... parameters)

Overrides javafx.scene.control.Control.executeAccessibleAction.

This method is called by the assistive technology to request the action indicated by the argument should be executed.

public abstract void
fire()

Invoked when a user gesture indicates that an event for this ButtonBase should occur.

public final EventHandler<ActionEvent>
public final boolean
public final ObjectProperty<EventHandler<ActionEvent>>

Returns:

the property to represent the button's action, which is invoked whenever the button is fired
onActionProperty
()

The button's action, which is invoked whenever the button is fired.

private void
setArmed(boolean value)

public final void
Inherited from javafx.scene.control.Labeled:
alignmentPropertycontentDisplayPropertyellipsisStringPropertyfontPropertygetAlignmentgetClassCssMetaDatagetContentBiasgetContentDisplaygetControlCssMetaDatagetEllipsisStringgetFontgetGraphicgetGraphicTextGapgetInitialAlignmentgetLabelPaddinggetLineSpacinggetTextgetTextAlignmentgetTextFillgetTextOverrungraphicPropertygraphicTextGapPropertyisMnemonicParsingisTextTruncatedisUnderlineisWrapTextlabelPaddingPropertylineSpacingPropertymnemonicParsingPropertysetAlignmentsetContentDisplaysetEllipsisStringsetFontsetGraphicsetGraphicTextGapsetLineSpacingsetMnemonicParsingsetTextsetTextAlignmentsetTextFillsetTextOverrunsetUnderlinesetWrapTexttextAlignmentPropertytextFillPropertytextOverrunPropertytextPropertytextTruncatedPropertytoStringunderlinePropertywrapTextProperty

Field Detail

armedback to summary
private ReadOnlyBooleanWrapper armed
ARMED_PSEUDOCLASS_STATEback to summary
private static final PseudoClass ARMED_PSEUDOCLASS_STATE
onActionback to summary
private ObjectProperty<EventHandler<ActionEvent>> onAction

Constructor Detail

ButtonBaseback to summary
public ButtonBase()

Create a default ButtonBase with empty text.

ButtonBaseback to summary
public ButtonBase(String text)

Create a ButtonBase with the given text.

Parameters
text:String

null text is treated as the empty string

ButtonBaseback to summary
public ButtonBase(String text, Node graphic)

Create a ButtonBase with the given text and graphic.

Parameters
text:String

null text is treated as the empty string

graphic:Node

a null graphic is acceptable

Method Detail

armback to summary
public void arm()

Arms the button. An armed button will fire an action (whether that be the action of a Button or toggling selection on a CheckBox or some other behavior) on the next expected UI gesture.

Note

This function is intended to be used by experts, primarily by those implementing new Skins or Behaviors. It is not common for developers or designers to access this function directly.

armedPropertyback to summary
public final ReadOnlyBooleanProperty armedProperty()

Indicates that the button has been "armed" such that a mouse release will cause the button's action to be invoked. This is subtly different from pressed. Pressed indicates that the mouse has been pressed on a Node and has not yet been released. arm however also takes into account whether the mouse is actually over the button and pressed.

Returns:ReadOnlyBooleanProperty

the property to indicate that the button has been "armed"

disarmback to summary
public void disarm()

Disarms the button. See arm().

Note

This function is intended to be used by experts, primarily by those implementing new Skins or Behaviors. It is not common for developers or designers to access this function directly.

executeAccessibleActionback to summary
public void executeAccessibleAction(AccessibleAction action, Object... parameters)

Overrides javafx.scene.control.Control.executeAccessibleAction.

Doc from javafx.scene.control.Control.executeAccessibleAction.

This method is called by the assistive technology to request the action indicated by the argument should be executed.

This method is commonly overridden by subclasses to implement action that are required for a specific role.
If a particular action is not handled, the superclass implementation must be called.

Annotations
@Override
fireback to summary
public abstract void fire()

Invoked when a user gesture indicates that an event for this ButtonBase should occur.

If invoked, this method will be executed regardless of the status of arm.

getOnActionback to summary
public final EventHandler<ActionEvent> getOnAction()
isArmedback to summary
public final boolean isArmed()
onActionPropertyback to summary
public final ObjectProperty<EventHandler<ActionEvent>> onActionProperty()

The button's action, which is invoked whenever the button is fired. This may be due to the user clicking on the button with the mouse, or by a touch event, or by a key press, or if the developer programmatically invokes the fire() method.

Returns:ObjectProperty<EventHandler<ActionEvent>>

the property to represent the button's action, which is invoked whenever the button is fired

setArmedback to summary
private void setArmed(boolean value)
setOnActionback to summary
public final void setOnAction(EventHandler<ActionEvent> value)