Class SplitMenuButton

  • All Implemented Interfaces:
    Styleable, EventTarget, Skinnable

    public class SplitMenuButton
    extends MenuButton
    The SplitMenuButton, like the 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(e -> System.out.println("Shutdown"));
    Image of the SplitMenuButton control

    MnemonicParsing is enabled by default for SplitMenuButton.

    Since:
    JavaFX 2.0
    See Also:
    MenuItem, Menu
    • Constructor Detail

      • SplitMenuButton

        public SplitMenuButton​(MenuItem... items)
        Creates a new split menu button with the given list of menu items.
        Parameters:
        items - The items to show within this button's menu
    • Method Detail

      • fire

        public void fire()
        Call the action when button is pressed.
        Overrides:
        fire in class MenuButton
      • createDefaultSkin

        protected Skin<?> 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(...).
        Overrides:
        createDefaultSkin in class MenuButton
        Returns:
        new instance of default skin for this control. If null then the control will have no skin unless one is provided by css.
      • queryAccessibleAttribute

        public Object queryAccessibleAttribute​(AccessibleAttribute attribute,
                                               Object... parameters)
        This method is called by the assistive technology to request the value for an attribute.

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

        Overrides:
        queryAccessibleAttribute in class Control
        Parameters:
        attribute - the requested attribute
        parameters - optional list of parameters
        Returns:
        the value for the requested attribute
        See Also:
        AccessibleAttribute
      • executeAccessibleAction

        public void executeAccessibleAction​(AccessibleAction action,
                                            Object... parameters)
        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.

        Overrides:
        executeAccessibleAction in class MenuButton
        Parameters:
        action - the action to execute
        parameters - optional list of parameters
        See Also:
        AccessibleAction