Class SplitMenuButton

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.AbstractButton
javax.swing.JMenuItem
javax.swing.JMenu
com.jidesoft.swing.JideMenu
com.jidesoft.swing.JideSplitButton
ro.sync.ui.ApplicationSplitButton
ro.sync.exml.workspace.api.standalone.ui.SplitMenuButton
All Implemented Interfaces:
com.jidesoft.swing.Alignable, com.jidesoft.swing.ButtonStyle, com.jidesoft.swing.ComponentStateSupport, ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, MenuElement, SwingConstants

@API(type=EXTENDABLE, src=PUBLIC) public class SplitMenuButton extends ro.sync.ui.ApplicationSplitButton
A component representing a combination of a button and a menu. There is a line in the component that splits it into the two aforementioned sub-components. The part before the line is a button, and can be clicked in order to trigger an action. The part after the line is a menu.

Code sample:
 SplitMenuButton splitMenuButton = new SplitMenuButton(
       // No default text
       null,
       // No default icon
       null,
       // Text can update when selecting an action
       false,
       // Icon can update when selecting an action
       false,
       // Don't always show the menu. Rather execute the current action.
       false,
       // Promote the last executed action as the default one.
       true);
       
 // Populate the menu
 List actions = getOrCreateActions();
 splitMenuButton.setMenuActions(actions);
 
 // Set the current action
 splitMenuButton.setCurrentAction(actions.get(0));
 
IMPORTANT: it is strongly recommended to use the methods exposed by this class for adding/setting actions, and not the ones that come from the super classes.

Since:
19.0
See Also:
  • Constructor Details

    • SplitMenuButton

      public SplitMenuButton(String defaultText, Icon defaultIcon, boolean updateText, boolean updateIcon, boolean alwaysShowMenu, boolean setSelectedActionAsDefault)
      Constructor.
      Parameters:
      defaultText - The default text, used when there is no action set explicitly. Can be null.
      defaultIcon - The default icon, used when there is no action set explicitly. Can be null.
      updateText - true to update the text of the button when selecting an action.
      updateIcon - true to update the icon of the button when selecting an action.
      alwaysShowMenu - true if pressing the button should always display the associated menu.
      setSelectedActionAsDefault - true to promote the selected action, setting it as the current/default action of the button.
  • Method Details

    • setMenuActions

      public void setMenuActions(List actions)
      Sets the menu actions. All other previous actions (if any) are removed.
      Parameters:
      actions - The list of actions to set in the menu.
    • setCurrentAction

      public void setCurrentAction(Action action)
      Sets the given action as the current/default one.
      Parameters:
      action - The action to be set as the current/default one.
    • addActionToMenu

      public void addActionToMenu(Action action, boolean canSetActionAsDefault)
      Adds an action to the end of the menu.
      Parameters:
      action - The list of actions to be added.
      canSetActionAsDefault - True if this action can be set as the current/default action for the button.
    • addActionsToMenu

      public void addActionsToMenu(List actions)
      Adds a list of actions to the end of the menu.
      Parameters:
      actions - The list of actions to be added.
    • insertAction

      public void insertAction(Action action, int position)
      Inserts an action at the given position in the menu.
      Parameters:
      action - The action to add.
      position - The position in the menu where the action is to be added.