Class SelectList<T>


  • public final class SelectList<T>
    extends AbstractListSection
    A scrollable, selectable list of typed items, each rendered to a display string; ENTER fires the selection handlers.
    • Constructor Detail

      • SelectList

        public SelectList()
        Creates an empty list.
      • SelectList

        public SelectList​(java.util.List<T> items)
        Creates a list populated with the given items.
        Parameters:
        items - the initial items
    • Method Detail

      • setItems

        public SelectList<T> setItems​(java.util.List<T> newItems)
        Replaces the items with the given list.
        Parameters:
        newItems - the new items
        Returns:
        this SelectList for chaining
      • renderer

        public SelectList<T> renderer​(java.util.function.Function<T,​java.lang.String> renderer)
        Sets the function that renders each item to a display string.
        Parameters:
        renderer - the item-to-string function
        Returns:
        this SelectList for chaining
      • selectedItem

        public T selectedItem()
        Returns:
        the selected item, or null when the list is empty
      • onSelectItem

        public SelectList<T> onSelectItem​(java.util.function.Consumer<T> handler)
        Sets the handler called with the item on ENTER.
        Parameters:
        handler - the item activation handler
        Returns:
        this SelectList for chaining
      • onSelect

        public SelectList<T> onSelect​(java.util.function.IntConsumer handler)
        Description copied from class: AbstractListSection
        Sets the handler called with the row index on ENTER.
        Overrides:
        onSelect in class AbstractListSection
        Parameters:
        handler - the activation handler
        Returns:
        this AbstractListSection for chaining