Top Description Fields Constructors Methods
javafx.scene.control

public Class Button

extends ButtonBase
Class Inheritance
Known Direct Subclasses
com.sun.javafx.scene.control.EmbeddedTextContextMenuContent.MenuItemContainer
Imports
javafx.beans.property.BooleanProperty, .BooleanPropertyBase, javafx.event.ActionEvent, javafx.scene.AccessibleRole, .Node, javafx.css.PseudoClass, javafx.scene.control.skin.ButtonSkin

A simple button control. The button control can contain text and/or a graphic. A button control has three different modes

When a button is pressed and released a ActionEvent is sent. Your application can perform some action based on this event by implementing an javafx.event.EventHandler to process the ActionEvent. Buttons can also respond to mouse events by implementing an javafx.event.EventHandler to process the javafx.scene.input.MouseEvent

MnemonicParsing is enabled by default for Button.

Example:

Button button = new Button("Click Me");
Image of the Button control
Since
JavaFX 2.0

Field Summary

Modifier and TypeField and Description
private BooleanProperty
cancelButton

A Cancel Button is the button that receives a keyboard VK_ESC press, if no other node in the scene consumes it.

private static final String
DEFAULT_STYLE_CLASS

Initialize the style class to 'button'.

private BooleanProperty
defaultButton

A default Button is the button that receives a keyboard VK_ENTER press, if no other node in the scene consumes it.

private static final PseudoClass
private static final PseudoClass

Constructor Summary

AccessConstructor and Description
public
Button()

Creates a button with an empty string for its label.

public
Button(String
A text string for its label.
text
)

Creates a button with the specified text as its label.

public
Button(String
A text string for its label.
text
,
Node
the icon for its label.
graphic
)

Creates a button with the specified text and icon for its label.

Method Summary

Modifier and TypeMethod and Description
public final BooleanProperty
protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control.

public final BooleanProperty
public void
fire()

Implements abstract javafx.scene.control.ButtonBase.fire.

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

private void
public final boolean
public final boolean
public final void
setCancelButton(boolean value)

public final void
setDefaultButton(boolean value)

Inherited from javafx.scene.control.ButtonBase:
armarmedPropertydisarmexecuteAccessibleActiongetOnActionisArmedonActionPropertysetOnAction

Field Detail

cancelButtonback to summary
private BooleanProperty cancelButton

A Cancel Button is the button that receives a keyboard VK_ESC press, if no other node in the scene consumes it.

DEFAULT_STYLE_CLASSback to summary
private static final String DEFAULT_STYLE_CLASS

Initialize the style class to 'button'. This is the selector class from which CSS can be used to style this control.

defaultButtonback to summary
private BooleanProperty defaultButton

A default Button is the button that receives a keyboard VK_ENTER press, if no other node in the scene consumes it.

PSEUDO_CLASS_CANCELback to summary
private static final PseudoClass PSEUDO_CLASS_CANCEL
PSEUDO_CLASS_DEFAULTback to summary
private static final PseudoClass PSEUDO_CLASS_DEFAULT

Constructor Detail

Buttonback to summary
public Button()

Creates a button with an empty string for its label.

Buttonback to summary
public Button(String text)

Creates a button with the specified text as its label.

Parameters
text:String

A text string for its label.

Buttonback to summary
public Button(String text, Node graphic)

Creates a button with the specified text and icon for its label.

Parameters
text:String

A text string for its label.

graphic:Node

the icon for its label.

Method Detail

cancelButtonPropertyback to summary
public final BooleanProperty cancelButtonProperty()
createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Doc from javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control. This is called to create a skin for the control if no skin is provided via CSS -fx-skin or set explicitly in a sub-class with setSkin(...).

Returns:Skin<?>

new instance of default skin for this control. If null then the control will have no skin unless one is provided by css.

Annotations
@Override
defaultButtonPropertyback to summary
public final BooleanProperty defaultButtonProperty()
fireback to summary
public void fire()

Implements abstract javafx.scene.control.ButtonBase.fire.

Doc from javafx.scene.control.ButtonBase.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.

Annotations
@Override
initializeback to summary
private void initialize()
isCancelButtonback to summary
public final boolean isCancelButton()
isDefaultButtonback to summary
public final boolean isDefaultButton()
setCancelButtonback to summary
public final void setCancelButton(boolean value)
setDefaultButtonback to summary
public final void setDefaultButton(boolean value)