Class KButtonGroup<K extends AbstractButton>

    • Constructor Detail

      • KButtonGroup

        @SafeVarargs
        public KButtonGroup​(K... buttons)
        Constructs group with the specified buttons. The first added button will be automatically selected.
        Parameters:
        buttons - Buttons to add to the group.
      • KButtonGroup

        public KButtonGroup​(Collection<K> buttons)
        Constructs group with the specified buttons. The first added button will be automatically selected.
        Parameters:
        buttons - Buttons to add to the group.
      • KButtonGroup

        public KButtonGroup​(boolean autoSelectFirstButton)
        Constructs an empty group.
        Parameters:
        autoSelectFirstButton - If true, the first added button will be automatically selected via AbstractButton.setSelected(boolean).
    • Method Detail

      • addButton

        public void addButton​(K button)
        Parameters:
        button - Button to add to the group. Not null.
      • addButtons

        @SafeVarargs
        public final void addButtons​(K... buttons)
      • addListener

        public void addListener​(KButtonGroupListener<K> listener)
        KButtonGroupEvent will be fired when there is a new selected button in the group.
        Implementation Specification:
        No event is fired if the selection becomes empty.
      • getButton

        public K getButton​(int index)
        Returns:
        Button at the specified index.
      • getSelectedButton

        public K getSelectedButton()
        Returns:
        The group's selected button or null if no button is selected.
      • getSelectedIndex

        public int getSelectedIndex()
        Returns:
        Index of the group's selected button or -1 if no button is selected.
      • getLastIndex

        public int getLastIndex()
        Returns:
        Maximum button index in the group.
        Throws:
        NoSuchElementException - If the group is empty.
      • setSelectedIndex

        public void setSelectedIndex​(int index)
        Parameters:
        index - Index of the button to select.
        See Also:
        getSelectedIndex()
      • getButtons

        public List<K> getButtons()
        Returns:
        Buttons of this group as unmodifiable List.
      • isAutoSelectFirstButton

        public boolean isAutoSelectFirstButton()