Package jexer
Class TList
- java.lang.Object
-
- jexer.TWidget
-
- jexer.TScrollableWidget
-
- jexer.TList
-
- All Implemented Interfaces:
java.lang.Comparable<TWidget>,Scrollable
- Direct Known Subclasses:
TDirectoryList
public class TList extends TScrollableWidget
TList shows a list of strings, and lets the user select one.
-
-
Field Summary
Fields Modifier and Type Field Description protected TActionenterActionThe action to perform when the user selects an item (double-clicks or enter).protected TActionmoveActionThe action to perform when the user navigates with keyboard.protected TActionsingleClickActionThe action to perform when the user selects an item (single-click).-
Fields inherited from class jexer.TScrollableWidget
hScroller, vScroller
-
-
Constructor Summary
Constructors Constructor Description TList(TWidget parent, java.util.List<java.lang.String> strings, int x, int y, int width, int height)Public constructor.TList(TWidget parent, java.util.List<java.lang.String> strings, int x, int y, int width, int height, TAction enterAction)Public constructor.TList(TWidget parent, java.util.List<java.lang.String> strings, int x, int y, int width, int height, TAction enterAction, TAction moveAction)Public constructor.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispatchEnter()Perform user selection action.voiddispatchMove()Perform list movement action.voiddispatchSingleClick()Perform single-click action.voiddraw()Draw the list.java.util.List<java.lang.String>getList()Get a copy of the list of strings to display.java.lang.StringgetListItem(int idx)Get a selectable string by index.intgetMaxSelectedIndex()Get the maximum selection index value.java.lang.StringgetSelected()Get the selected string.intgetSelectedIndex()Get the selection index.voidonKeypress(TKeypressEvent keypress)Handle keystrokes.voidonMouseDoubleClick(TMouseEvent mouse)Handle mouse double click.voidonMouseDown(TMouseEvent mouse)Handle mouse press events.voidreflowData()Resize for a new width/height.voidsetHeight(int height)Override TWidget's height: we need to set child widget heights.voidsetList(java.util.List<java.lang.String> list)Set the new list of strings to display.voidsetSelectedIndex(int index)Set the selected string index.voidsetWidth(int width)Override TWidget's width: we need to set child widget widths.-
Methods inherited from class jexer.TScrollableWidget
bigHorizontalDecrement, bigHorizontalIncrement, bigVerticalDecrement, bigVerticalIncrement, getBottomValue, getHorizontalBigChange, getHorizontalScroller, getHorizontalSmallChange, getHorizontalValue, getLeftValue, getRightValue, getTopValue, getVerticalBigChange, getVerticalScroller, getVerticalSmallChange, getVerticalValue, horizontalDecrement, horizontalIncrement, onResize, placeScrollbars, setBottomValue, setHorizontalBigChange, setHorizontalSmallChange, setHorizontalValue, setLeftValue, setRightValue, setTopValue, setVerticalBigChange, setVerticalSmallChange, setVerticalValue, toBottom, toEnd, toHome, toLeft, toRight, toTop, verticalDecrement, verticalIncrement
-
Methods inherited from class jexer.TWidget
activate, activate, activate, activateAll, addButton, addCalendar, addCheckBox, addCheckBox, addComboBox, addDirectoryList, addDirectoryList, addDirectoryList, addDirectoryList, addEditor, addField, addField, addField, addField, addImage, addImage, addImage, addImage, addLabel, addLabel, addLabel, addLabel, addLabel, addLabel, addList, addList, addList, addList, addPanel, addPasswordField, addPasswordField, addPasswordField, addProgressBar, addRadioGroup, addRadioGroup, addSpinner, addSplitPane, addTable, addTable, addText, addText, addTreeViewWidget, addTreeViewWidget, close, compareTo, doRepaint, drawBox, drawBox, drawBoxShadow, drawChildren, fileOpenBox, fileOpenBox, fileOpenBox, fileOpenBox, fileSaveBox, getAbsoluteX, getAbsoluteY, getActiveChild, getApplication, getAttrXY, getChildren, getClipboard, getCursorAbsoluteX, getCursorAbsoluteY, getCursorX, getCursorY, getCustomMousePointer, getHeight, getLayoutManager, getLocale, getMouseStyle, getParent, getScreen, getTheme, getWidgetUnderMouse, getWidth, getWindow, getX, getY, handleEvent, hasChild, hLineXY, hLineXY, inputBox, inputBox, inputBox, isAbsoluteActive, isActive, isCursorVisible, isDrawable, isEchoKeystrokes, isEnabled, isPixelMouse, isVisible, messageBox, messageBox, mouseWouldHit, onCommand, onIdle, onMenu, onMouseMotion, onMouseUp, putAll, putAttrXY, putAttrXY, putCharXY, putCharXY, putCharXY, putStringXY, putStringXY, remove, remove, remove, remove, removeAll, resetTabOrder, setActive, setCursorVisible, setCursorX, setCursorY, setCustomMousePointer, setDimensions, setEchoKeystrokes, setEchoKeystrokes, setEnabled, setLayoutManager, setLocale, setMouseStyle, setParent, setupForTWindow, setVisible, setWindow, setX, setY, splitHorizontal, splitVertical, switchWidget, toPrettyString, toPrettyString, toString, vLineXY, vLineXY
-
-
-
-
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 widgetstrings- list of strings to showx- column relative to parenty- row relative to parentwidth- width of text areaheight- 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 widgetstrings- list of strings to show. This is allowed to be null and set later with setList() or by subclasses.x- column relative to parenty- row relative to parentwidth- width of text areaheight- height of text areaenterAction- 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 widgetstrings- list of strings to show. This is allowed to be null and set later with setList() or by subclasses.x- column relative to parenty- row relative to parentwidth- width of text areaheight- height of text areaenterAction- action to perform when an item is selectedmoveAction- 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 widgetstrings- list of strings to show. This is allowed to be null and set later with setList() or by subclasses.x- column relative to parenty- row relative to parentwidth- width of text areaheight- height of text areaenterAction- action to perform when an item is selectedmoveAction- action to perform when the user navigates to a new item with arrow/page keyssingleClickAction- action to perform when the user clicks on an item
-
-
Method Detail
-
onMouseDown
public void onMouseDown(TMouseEvent mouse)
Handle mouse press events.- Overrides:
onMouseDownin classTWidget- Parameters:
mouse- mouse button press event
-
onMouseDoubleClick
public void onMouseDoubleClick(TMouseEvent mouse)
Handle mouse double click.- Overrides:
onMouseDoubleClickin classTWidget- Parameters:
mouse- mouse double click event
-
onKeypress
public void onKeypress(TKeypressEvent keypress)
Handle keystrokes.- Overrides:
onKeypressin classTWidget- Parameters:
keypress- keystroke event
-
setWidth
public void setWidth(int width)
Override TWidget's width: we need to set child widget widths.
-
setHeight
public void setHeight(int height)
Override TWidget's height: we need to set child widget heights.
-
reflowData
public void reflowData()
Resize for a new width/height.- Overrides:
reflowDatain classTScrollableWidget
-
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.
-
-