A simple button control. The button control can contain text and/or a graphic. A button control has three different modes
ENTER
key presses when it has focus. When the default button does not have focus, and focus is on another Button
control, the ENTER key press will be received by the other, non-default Button. When focus is elsewhere in
the user interface, and not on any Button, the ENTER key press will be received by the default button, if
one is specified, and if no other node in the scene consumes it first.SPACE key.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. to process the ActionEvent. Buttons can also respond to
mouse events by implementing an javafx. to process the javafx.
MnemonicParsing is enabled by default for Button.
Example:
Button button = new Button("Click Me");
| Modifier and Type | Field 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 |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public final BooleanProperty | |
| protected Skin | createDefaultSkin()
Overrides javafx. Create a new instance of the default skin for this control. |
| public final BooleanProperty | |
| public void | fire()
Implements abstract javafx. Invoked when a user gesture indicates that an event for this
|
| private void | |
| public final boolean | |
| public final boolean | |
| public final void | |
| public final void |
| cancelButton | back 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_CLASS | back 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. | |
| defaultButton | back 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_CANCEL | back to summary |
|---|---|
| private static final PseudoClass PSEUDO_CLASS_CANCEL | |
| PSEUDO_CLASS_DEFAULT | back to summary |
|---|---|
| private static final PseudoClass PSEUDO_CLASS_DEFAULT | |
| Button | back to summary |
|---|---|
| public Button() Creates a button with an empty string for its label. | |
| Button | back to summary |
|---|---|
| public Button(String text) Creates a button with the specified text as its label.
| |
| Button | back to summary |
|---|---|
| public Button(String text, Node graphic) Creates a button with the specified text and icon for its label. | |
| cancelButtonProperty | back to summary |
|---|---|
| public final BooleanProperty cancelButtonProperty() | |
| createDefaultSkin | back to summary |
|---|---|
| protected Skin Overrides javafx. Doc from javafx. 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
| |
| defaultButtonProperty | back to summary |
|---|---|
| public final BooleanProperty defaultButtonProperty() | |
| fire | back to summary |
|---|---|
| public void fire() Implements abstract javafx. Doc from javafx. Invoked when a user gesture indicates that an event for this
If invoked, this method will be executed regardless of the status of
| |
| initialize | back to summary |
|---|---|
| private void initialize() | |
| isCancelButton | back to summary |
|---|---|
| public final boolean isCancelButton() | |
| isDefaultButton | back to summary |
|---|---|
| public final boolean isDefaultButton() | |
| setCancelButton | back to summary |
|---|---|
| public final void setCancelButton(boolean value) | |
| setDefaultButton | back to summary |
|---|---|
| public final void setDefaultButton(boolean value) | |