Class SplitButton

All Implemented Interfaces:
Animation, Editable, StyleListener, Iterable<Component>

public class SplitButton extends Container

A button with a main action and an arrow beside it that opens more actions.

SplitButton save = new SplitButton("Save");
save.addActionListener(e -> Log.p("Save"));
save.addMenuAction("Save as...", e -> Log.p("Save as"));
save.addMenuAction("Save a copy", e -> Log.p("Save a copy"));

The arrow opens the other actions in an action Sheet (Sheet.addAction). The two halves use the UIIDs SplitButton and SplitButtonArrow.

  • Constructor Details

    • SplitButton

      public SplitButton(String text)

      A split button with the given text on its main half.

      Parameters
      • text: the text of the main action
  • Method Details

    • getMainButton

      public Button getMainButton()
      The button of the main action.
    • getArrowButton

      public Button getArrowButton()
      The arrow that opens the other actions.
    • addActionListener

      public void addActionListener(ActionListener l)

      Adds a listener for the main action.

      Parameters
      • l: the listener
    • removeActionListener

      public void removeActionListener(ActionListener l)

      Removes a listener of the main action.

      Parameters
      • l: the listener
    • addMenuAction

      public void addMenuAction(String text, ActionListener l)

      Adds an action to the menu behind the arrow.

      Parameters
      • text: the label of the action
      • l: called when it is picked
    • getMenuActionCount

      public int getMenuActionCount()
      The number of actions behind the arrow.
    • showMenu

      public void showMenu()
      Opens the menu of other actions.