Component
, Interactable
, TextGUIElement
public class CheckBoxList<V> extends AbstractListBox<V,CheckBoxList<V>>
Modifier and Type | Class | Description |
---|---|---|
static class |
CheckBoxList.CheckBoxListItemRenderer<V> |
Default renderer for this component which is used unless overridden.
|
static interface |
CheckBoxList.Listener |
Listener interface that can be attached to the
CheckBoxList in order to be notified on user actions |
AbstractListBox.DefaultListBoxRenderer<V,T extends AbstractListBox<V,T>>, AbstractListBox.ListItemRenderer<V,T extends AbstractListBox<V,T>>
Interactable.FocusChangeDirection, Interactable.Result
scrollOffset
Constructor | Description |
---|---|
CheckBoxList() |
Creates a new
CheckBoxList that is initially empty and has no hardcoded preferred size, so it will
attempt to be as big as necessary to draw all items. |
CheckBoxList(TerminalSize preferredSize) |
Creates a new
CheckBoxList that is initially empty and has a pre-defined size that it will request. |
Modifier and Type | Method | Description |
---|---|---|
CheckBoxList<V> |
addItem(V object) |
Adds one more item to the list box, at the end.
|
CheckBoxList<V> |
addItem(V object,
boolean checkedState) |
Adds an item to the checkbox list with an explicit checked status
|
CheckBoxList<V> |
addListener(CheckBoxList.Listener listener) |
Adds a new listener to the
CheckBoxList that will be called on certain user actions |
CheckBoxList<V> |
clearItems() |
Removes all items from the list box
|
protected AbstractListBox.ListItemRenderer<V,CheckBoxList<V>> |
createDefaultListItemRenderer() |
Method that constructs the
ListItemRenderer that this list box should use to draw the elements of the
list box. |
List<V> |
getCheckedItems() |
Returns all the items in the list box that have checked state, as a list
|
Interactable.Result |
handleKeyStroke(KeyStroke keyStroke) |
This method can be overridden to handle various user input (mostly from the keyboard) when this component is in
focus.
|
Boolean |
isChecked(int index) |
Checks if a particular item is part of the check box list and returns a boolean value depending on the toggle
state of the item.
|
Boolean |
isChecked(V object) |
Checks if a particular item is part of the check box list and returns a boolean value depending on the toggle
state of the item.
|
V |
removeItem(int index) |
Removes an item from the list box by its index.
|
CheckBoxList<V> |
removeListener(CheckBoxList.Listener listener) |
Removes a listener from this
CheckBoxList so that if it had been added earlier, it will no longer be
called on user actions |
CheckBoxList<V> |
setChecked(V object,
boolean checked) |
Programmatically sets the checked state of an item in the list box
|
CheckBoxList<V> |
toggleChecked(int index) |
Programmatically sets the checked state of an item in the list box.
|
addTo, calculatePreferredSize, draw, getBasePane, getGlobalPosition, getLayoutData, getParent, getPosition, getPreferredSize, getSize, getTextGUI, getTheme, getThemeDefinition, hasParent, invalidate, isInside, isInvalid, isVisible, onAdded, onAfterDrawing, onBeforeDrawing, onRemoved, runOnGUIThreadIfExistsOtherwiseRunDirect, self, setLayoutData, setPosition, setPreferredSize, setRenderer, setSize, setTheme, setVisible, toBasePane, toGlobal, withBorder
afterLeaveFocus, getCursorLocation, getInputFilter, getRenderer, handleInput, isActivationStroke, isEnabled, isFocused, isKeyboardActivationStroke, isMouseActivationStroke, isMouseDown, isMouseDrag, isMouseMove, isMouseUp, onEnterFocus, onLeaveFocus, setEnabled, setInputFilter, takeFocus
afterEnterFocus, createDefaultRenderer, getIndexByMouseAction, getItemAt, getItemCount, getItems, getSelectedIndex, getSelectedItem, indexOf, isEmpty, isFocusable, setListItemRenderer, setSelectedIndex
addTo, getBasePane, getGlobalPosition, getLayoutData, getParent, getPosition, getPreferredSize, getSize, getTextGUI, getTheme, getThemeDefinition, hasParent, invalidate, isInside, isVisible, onAdded, onRemoved, setLayoutData, setPosition, setPreferredSize, setSize, setTheme, setVisible, toBasePane, toGlobal, withBorder
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
draw, isInvalid
public CheckBoxList()
CheckBoxList
that is initially empty and has no hardcoded preferred size, so it will
attempt to be as big as necessary to draw all items.public CheckBoxList(TerminalSize preferredSize)
CheckBoxList
that is initially empty and has a pre-defined size that it will request. If
there are more items that can fit in this size, the list box will use scrollbars.preferredSize
- Size the list box should request, no matter how many items it containsprotected AbstractListBox.ListItemRenderer<V,CheckBoxList<V>> createDefaultListItemRenderer()
AbstractListBox
ListItemRenderer
that this list box should use to draw the elements of the
list box. This can be overridden to supply a custom renderer. Note that this is not the renderer used for the
entire list box but for each item, called one by one.createDefaultListItemRenderer
in class AbstractListBox<V,CheckBoxList<V>>
ListItemRenderer
to use when drawing the items in the listpublic CheckBoxList<V> clearItems()
AbstractListBox
clearItems
in class AbstractListBox<V,CheckBoxList<V>>
public CheckBoxList<V> addItem(V object)
AbstractListBox
addItem
in class AbstractListBox<V,CheckBoxList<V>>
object
- Item to add to the list boxpublic V removeItem(int index)
AbstractListBox
removeItem
in class AbstractListBox<V,CheckBoxList<V>>
index
- Index of the item to removepublic CheckBoxList<V> addItem(V object, boolean checkedState)
object
- Object to add to the listcheckedState
- If true
, the new item will be initially checkedpublic Boolean isChecked(V object)
object
- Object to check the status ofnull
is returned, otherwise true
or
false
depending on checked state of the itempublic Boolean isChecked(int index)
index
- Index of the item to check the status ofnull
is returned, otherwise true
or
false
depending on checked state of the item at that indexpublic CheckBoxList<V> toggleChecked(int index)
index
- Index of the item to toggle the status ofpublic CheckBoxList<V> setChecked(V object, boolean checked)
object
- Object to set the checked state ofchecked
- If true
, then the item is set to checked, otherwise notpublic List<V> getCheckedItems()
public CheckBoxList<V> addListener(CheckBoxList.Listener listener)
CheckBoxList
that will be called on certain user actionslistener
- Listener to attach to this CheckBoxList
public CheckBoxList<V> removeListener(CheckBoxList.Listener listener)
CheckBoxList
so that if it had been added earlier, it will no longer be
called on user actionslistener
- Listener to remove from this CheckBoxList
public Interactable.Result handleKeyStroke(KeyStroke keyStroke)
AbstractInteractableComponent
handleInput(..)
is final in
AbstractInteractableComponent
to ensure the input filter is properly handled. If the filter decides that
this event should be processed, it will call this method.handleKeyStroke
in class AbstractListBox<V,CheckBoxList<V>>
keyStroke
- What input was entered by the userCopyright © 2020. All rights reserved.