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:
  • Constructor Details

    • SplitMenuButton

      public SplitMenuButton()
      Creates a new empty split menu button. Use Labeled.setText(String), Labeled.setGraphic(Node) and MenuButton.getItems() to set the content.
    • SplitMenuButton

      public SplitMenuButton(String text)
      Creates a new empty split menu button with the given text to display on the button. Use Labeled.setGraphic(Node) and MenuButton.getItems() to set the content.
      Parameters:
      text - the text to display on the menu button
      Since:
      24
    • SplitMenuButton

      public SplitMenuButton(String text, Node graphic)
      Creates a new empty split menu button with the given text and graphic to display on the button. Use MenuButton.getItems() to set the content.
      Parameters:
      text - the text to display on the menu button
      graphic - the graphic to display on the menu button
      Since:
      24
    • 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
    • SplitMenuButton

      public SplitMenuButton(String text, Node graphic, MenuItem... items)
      Creates a new split menu button with the given text and graphic to display on the button, and inserts the given items into the items list.
      Parameters:
      text - the text to display on the menu button
      graphic - the graphic to display on the menu button
      items - the items to display in the popup menu
      Since:
      24
  • Method Details

    • fire

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