Package jexer

Class TList

    • Field Detail

      • enterAction

        protected TAction enterAction
        The action to perform when the user selects an item (double-clicks or enter).
      • singleClickAction

        protected TAction singleClickAction
        The action to perform when the user selects an item (single-click).
      • moveAction

        protected TAction moveAction
        The action to perform when the user navigates with keyboard.
    • Constructor Detail

      • TList

        public TList​(TWidget parent,
                     java.util.List<java.lang.String> strings,
                     int x,
                     int y,
                     int width,
                     int height)
        Public constructor.
        Parameters:
        parent - parent widget
        strings - list of strings to show
        x - column relative to parent
        y - row relative to parent
        width - width of text area
        height - height of text area
      • TList

        public TList​(TWidget parent,
                     java.util.List<java.lang.String> strings,
                     int x,
                     int y,
                     int width,
                     int height,
                     TAction enterAction)
        Public constructor.
        Parameters:
        parent - parent widget
        strings - list of strings to show. This is allowed to be null and set later with setList() or by subclasses.
        x - column relative to parent
        y - row relative to parent
        width - width of text area
        height - height of text area
        enterAction - action to perform when an item is selected
      • TList

        public TList​(TWidget parent,
                     java.util.List<java.lang.String> strings,
                     int x,
                     int y,
                     int width,
                     int height,
                     TAction enterAction,
                     TAction moveAction)
        Public constructor.
        Parameters:
        parent - parent widget
        strings - list of strings to show. This is allowed to be null and set later with setList() or by subclasses.
        x - column relative to parent
        y - row relative to parent
        width - width of text area
        height - height of text area
        enterAction - action to perform when an item is selected
        moveAction - action to perform when the user navigates to a new item with arrow/page keys
      • TList

        public TList​(TWidget parent,
                     java.util.List<java.lang.String> strings,
                     int x,
                     int y,
                     int width,
                     int height,
                     TAction enterAction,
                     TAction moveAction,
                     TAction singleClickAction)
        Public constructor.
        Parameters:
        parent - parent widget
        strings - list of strings to show. This is allowed to be null and set later with setList() or by subclasses.
        x - column relative to parent
        y - row relative to parent
        width - width of text area
        height - height of text area
        enterAction - action to perform when an item is selected
        moveAction - action to perform when the user navigates to a new item with arrow/page keys
        singleClickAction - action to perform when the user clicks on an item
    • Method Detail

      • onMouseDown

        public void onMouseDown​(TMouseEvent mouse)
        Handle mouse press events.
        Overrides:
        onMouseDown in class TWidget
        Parameters:
        mouse - mouse button press event
      • onMouseDoubleClick

        public void onMouseDoubleClick​(TMouseEvent mouse)
        Handle mouse double click.
        Overrides:
        onMouseDoubleClick in class TWidget
        Parameters:
        mouse - mouse double click event
      • onKeypress

        public void onKeypress​(TKeypressEvent keypress)
        Handle keystrokes.
        Overrides:
        onKeypress in class TWidget
        Parameters:
        keypress - keystroke event
      • setWidth

        public void setWidth​(int width)
        Override TWidget's width: we need to set child widget widths.
        Overrides:
        setWidth in class TWidget
        Parameters:
        width - new widget width
      • setHeight

        public void setHeight​(int height)
        Override TWidget's height: we need to set child widget heights.
        Overrides:
        setHeight in class TWidget
        Parameters:
        height - new widget height
      • draw

        public void draw()
        Draw the list.
        Overrides:
        draw in class TWidget
      • getSelectedIndex

        public final int getSelectedIndex()
        Get the selection index.
        Returns:
        -1 if nothing is selected, otherwise the index into the list
      • setSelectedIndex

        public final void setSelectedIndex​(int index)
        Set the selected string index.
        Parameters:
        index - -1 to unselect, otherwise the index into the list
      • getListItem

        public final java.lang.String getListItem​(int idx)
        Get a selectable string by index.
        Parameters:
        idx - index into list
        Returns:
        the string at idx in the list
      • getSelected

        public final java.lang.String getSelected()
        Get the selected string.
        Returns:
        the selected string, or null of nothing is selected yet
      • getMaxSelectedIndex

        public final int getMaxSelectedIndex()
        Get the maximum selection index value.
        Returns:
        -1 if the list is empty
      • getList

        public final java.util.List<java.lang.String> getList()
        Get a copy of the list of strings to display.
        Returns:
        the list of strings
      • setList

        public final void setList​(java.util.List<java.lang.String> list)
        Set the new list of strings to display.
        Parameters:
        list - new list of strings
      • dispatchEnter

        public void dispatchEnter()
        Perform user selection action.
      • dispatchMove

        public void dispatchMove()
        Perform list movement action.
      • dispatchSingleClick

        public void dispatchSingleClick()
        Perform single-click action.