Package swingtree

Class SplitButtonDelegate<I extends JMenuItem>

java.lang.Object
swingtree.AbstractDelegate<JSplitButton>
swingtree.SplitButtonDelegate<I>
Type Parameters:
I - The common type of the JMenuItem which is part of the JSplitButton.

public final class SplitButtonDelegate<I extends JMenuItem> extends AbstractDelegate<JSplitButton>
This class is a delegate for events of the JSplitButton component. See UIForSplitButton.onSplitClick(Action) or UIForSplitButton.onSelection(Action) for more information about where this delegate is used.
  • Method Details

    • getEvent

      public ActionEvent getEvent()
    • getSplitButton

      public JSplitButton getSplitButton()
      Exposes the underlying SplitItemDelegate instance.
      Returns:
      The JSplitButton to which this SplitItem (and its JMenuItem) belongs.
    • getCurrentItem

      public final I getCurrentItem()
      Exposes the JMenuItem which is currently selected.
      Returns:
      The JMenuItem which caused this action to be executed.
    • getSiblinghood

      public List<JComponent> getSiblinghood()
      The "siblinghood" of a component refers to all children of its parent component, including itself. This is contrary to the getSiblings() method which returns all children of the parent component except the current component.
      Returns:
      A list of all the JComponent siblings of the split button, including the split button itself.
    • getSiblings

      public List<JComponent> getSiblings()
      The "siblings" of a component refer to all children of its parent component, except itself. This is contrary to the getSiblinghood() method which returns all children of the parent component including the current component.
      Returns:
      A list of all the JComponent which constitute the neighbouring UI components of the split button. except the current JSplitButton itself.
    • selectCurrentItem

      public SplitButtonDelegate<I> selectCurrentItem()
      Selects the current JMenuItem by passing true to the AbstractButton.setSelected(boolean) method.
      Returns:
      This delegate instance to allow for method chaining.
    • selectOnlyCurrentItem

      public SplitButtonDelegate<I> selectOnlyCurrentItem()
      Selects only the current JMenuItem by passing true to the AbstractButton.setSelected(boolean) method. All other JMenuItems will be unselected.
      Returns:
      This delegate instance to allow for method chaining.
    • unselectCurrentItem

      public SplitButtonDelegate<I> unselectCurrentItem()
      Unselects the current JMenuItem by passing false to the AbstractButton.setSelected(boolean) method.
      Returns:
      This delegate instance to allow for method chaining.
    • unselectAllItems

      public SplitButtonDelegate<I> unselectAllItems()
      Unselects all JMenuItems by passing false to their AbstractButton.setSelected(boolean) methods.
      Returns:
      This delegate instance to allow for method chaining.
    • selectAllItems

      public SplitButtonDelegate<I> selectAllItems()
      Selects all JMenuItems by passing true to their AbstractButton.setSelected(boolean) methods.
      Returns:
      This delegate instance to allow for method chaining.
    • displayCurrentItemText

      public SplitButtonDelegate<I> displayCurrentItemText()
      Use this to conveniently make the JSplitButton display the text of the currently selected JMenuItem (button item).
      Returns:
      This delegate instance to allow for method chaining.
    • setButtonText

      public SplitButtonDelegate<I> setButtonText(String text)
      Allows you to set the text displayed on the JSplitButton inside of your user Action implementation.
      Parameters:
      text - The text which should be displayed on the JSplitButton.
      Returns:
      This delegate instance to allow for method chaining.
    • getButtonText

      public String getButtonText()
      A convenient getter method for accessing the text displayed on the JSplitButton. See also setButtonText(String) for setting the text displayed on the JSplitButton.
      Returns:
      The text displayed on the JSplitButton.
    • appendToButtonText

      public SplitButtonDelegate<I> appendToButtonText(String postfix)
      A convenience method to append text to the text displayed on the JSplitButton.
      Parameters:
      postfix - The text which should be appended to the text displayed on the JSplitButton.
      Returns:
      This delegate instance to allow for method chaining.
    • prependToButtonText

      public SplitButtonDelegate<I> prependToButtonText(String prefix)
      A convenience method to prepend text to the text displayed on the JSplitButton.
      Parameters:
      prefix - The text which should be prepended to the text displayed on the JSplitButton.
      Returns:
      This delegate instance to allow for method chaining.
    • selectItem

      public SplitButtonDelegate<I> selectItem(int i)
      Selects the targeted split item (JMenuItem).
      Parameters:
      i - The item index of the JMenuItem which should be selected.
      Returns:
      This delegate instance to allow for method chaining.
    • selectOnlyItem

      public SplitButtonDelegate<I> selectOnlyItem(int i)
      Selects the targeted split item (JMenuItem) and unselects all other items.
      Parameters:
      i - The item index of the JMenuItem which should be selected exclusively.
      Returns:
      This delegate instance to allow for method chaining.
    • unselectItem

      public SplitButtonDelegate<I> unselectItem(int i)
      Unselects the targeted split item (JMenuItem).
      Parameters:
      i - The item index of the JMenuItem which should be unselected.
      Returns:
      This delegate instance to allow for method chaining.