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 TAction
enterAction
The action to perform when the user selects an item (double-clicks or enter).protected TAction
moveAction
The action to perform when the user navigates with keyboard.protected TAction
singleClickAction
The 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 void
dispatchEnter()
Perform user selection action.void
dispatchMove()
Perform list movement action.void
dispatchSingleClick()
Perform single-click action.void
draw()
Draw the list.java.util.List<java.lang.String>
getList()
Get a copy of the list of strings to display.java.lang.String
getListItem(int idx)
Get a selectable string by index.int
getMaxSelectedIndex()
Get the maximum selection index value.java.lang.String
getSelected()
Get the selected string.int
getSelectedIndex()
Get the selection index.void
onKeypress(TKeypressEvent keypress)
Handle keystrokes.void
onMouseDoubleClick(TMouseEvent mouse)
Handle mouse double click.void
onMouseDown(TMouseEvent mouse)
Handle mouse press events.void
reflowData()
Resize for a new width/height.void
setHeight(int height)
Override TWidget's height: we need to set child widget heights.void
setList(java.util.List<java.lang.String> list)
Set the new list of strings to display.void
setSelectedIndex(int index)
Set the selected string index.void
setWidth(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, 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, getMouseStyle, getParent, getScreen, getTheme, getWidgetUnderMouse, getWidth, getWindow, getX, getY, handleEvent, hasChild, 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, setMouseStyle, setParent, setupForTWindow, setVisible, setWindow, setX, setY, splitHorizontal, splitVertical, switchWidget, toPrettyString, toPrettyString, toString, 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:
onMouseDown
in classTWidget
- Parameters:
mouse
- mouse button press event
-
onMouseDoubleClick
public void onMouseDoubleClick(TMouseEvent mouse)
Handle mouse double click.- Overrides:
onMouseDoubleClick
in classTWidget
- Parameters:
mouse
- mouse double click event
-
onKeypress
public void onKeypress(TKeypressEvent keypress)
Handle keystrokes.- Overrides:
onKeypress
in 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:
reflowData
in 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.
-
-