public class SplitMenuButton extends MenuButton
MenuButton
is closely associated with
the concept of selecting a MenuItem
from a menu. Unlike MenuButton
,
the SplitMenuButton is broken into two pieces, the "action" area and the
"menu open" area.
If the user clicks in the action area, the SplitMenuButton will act similarly
to a Button
, firing whatever is
associated with the ButtonBase.onAction
property.
The menu open area of the control will show a menu if clicked. When the user selects an item from the menu, it is executed.
Note that the SplitMenuButton does not automatically assign whatever was last selected in the menu to be the action should the action region be clicked.
Example:
SplitMenuButton m = new SplitMenuButton(); m.setText("Shutdown"); m.getItems().addAll(new MenuItem("Logout"), new MenuItem("Sleep")); m.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Shutdown"); } });
MnemonicParsing is enabled by default for SplitMenuButton.
onHiddenProperty, onHidingProperty, onShowingProperty, onShownProperty, popupSideProperty, showingProperty
armedProperty, onActionProperty
alignmentProperty, contentDisplayProperty, ellipsisStringProperty, fontProperty, graphicProperty, graphicTextGapProperty, labelPaddingProperty, lineSpacingProperty, mnemonicParsingProperty, textAlignmentProperty, textFillProperty, textOverrunProperty, textProperty, underlineProperty, wrapTextProperty
contextMenuProperty, skinClassNameProperty, skinProperty, tooltipProperty
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
DEFAULT_STYLE_CLASS
*
Stylesheet Handling *
*
|
ON_HIDDEN, ON_HIDING, ON_SHOWING, ON_SHOWN
Constructor and Description |
---|
SplitMenuButton()
Creates a new empty split menu button.
|
SplitMenuButton(MenuItem... items)
Creates a new split menu button with the given list of menu items.
|
Modifier and Type | Method and Description |
---|---|
protected Skin<?> |
createDefaultSkin()
Create a new instance of the default skin for this control.
|
void |
executeAccessibleAction(AccessibleAction action,
java.lang.Object... parameters) |
void |
fire()
Call the action when button is pressed.
|
java.lang.Object |
queryAccessibleAttribute(AccessibleAttribute attribute,
java.lang.Object... parameters) |
getItems, getOnHidden, getOnHiding, getOnShowing, getOnShown, getPopupSide, hide, isShowing, onHiddenProperty, onHidingProperty, onShowingProperty, onShownProperty, popupSideProperty, setOnHidden, setOnHiding, setOnShowing, setOnShown, setPopupSide, show, showingProperty
arm, armedProperty, disarm, getOnAction, isArmed, onActionProperty, setOnAction
alignmentProperty, contentDisplayProperty, ellipsisStringProperty, fontProperty, getAlignment, getClassCssMetaData, getContentBias, getContentDisplay, getControlCssMetaData, getEllipsisString, getFont, getGraphic, getGraphicTextGap, getInitialAlignment, getLabelPadding, getLineSpacing, getText, getTextAlignment, getTextFill, getTextOverrun, graphicProperty, graphicTextGapProperty, isMnemonicParsing, isUnderline, isWrapText, labelPaddingProperty, lineSpacingProperty, mnemonicParsingProperty, setAlignment, setContentDisplay, setEllipsisString, setFont, setGraphic, setGraphicTextGap, setLineSpacing, setMnemonicParsing, setText, setTextAlignment, setTextFill, setTextOverrun, setUnderline, setWrapText, textAlignmentProperty, textFillProperty, textOverrunProperty, textProperty, toString, underlineProperty, wrapTextProperty
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, getBaselineOffset, getContextMenu, getControlChildren, getCssMetaData, getInitialFocusTraversable, getSkin, getTooltip, isResizable, layoutChildren, loadSkinClass, setContextMenu, setSkin, setTooltip, skinClassNameProperty, skinProperty, tooltipProperty
private static final java.lang.String DEFAULT_STYLE_CLASS
public SplitMenuButton()
Labeled.setText(String)
,
Labeled.setGraphic(Node)
and MenuButton.getItems()
to set the content.public SplitMenuButton(MenuItem... items)
items
- The items to show within this button's menupublic void fire()
fire
in class MenuButton
protected Skin<?> createDefaultSkin()
-fx-skin
or set explicitly in a sub-class with setSkin(...)
.createDefaultSkin
in class MenuButton
public java.lang.Object queryAccessibleAttribute(AccessibleAttribute attribute, java.lang.Object... parameters)
queryAccessibleAttribute
in class Control
public void executeAccessibleAction(AccessibleAction action, java.lang.Object... parameters)
executeAccessibleAction
in class MenuButton