Component
, Interactable
, TextGUIElement
public class RadioBoxList<V> extends AbstractListBox<V,RadioBoxList<V>>
Modifier and Type | Class | Description |
---|---|---|
static interface |
RadioBoxList.Listener |
Listener interface that can be attached to the
RadioBoxList in order to be notified on user actions |
static class |
RadioBoxList.RadioBoxListItemRenderer<V> |
Default renderer for this component which is used unless overridden.
|
AbstractListBox.DefaultListBoxRenderer<V,T extends AbstractListBox<V,T>>, AbstractListBox.ListItemRenderer<V,T extends AbstractListBox<V,T>>
Interactable.FocusChangeDirection, Interactable.Result
Constructor | Description |
---|---|
RadioBoxList() |
Creates a new RadioCheckBoxList with no items.
|
RadioBoxList(TerminalSize preferredSize) |
Creates a new RadioCheckBoxList with a specified size.
|
Modifier and Type | Method | Description |
---|---|---|
RadioBoxList<V> |
addListener(RadioBoxList.Listener listener) |
Adds a new listener to the
RadioBoxList that will be called on certain user actions |
RadioBoxList<V> |
clearItems() |
Removes all items from the list box
|
void |
clearSelection() |
Un-checks the currently checked item (if any) and leaves the radio check box in a state where no item is checked.
|
protected AbstractListBox.ListItemRenderer<V,RadioBoxList<V>> |
createDefaultListItemRenderer() |
Method that constructs the
ListItemRenderer that this list box should use to draw the elements of the
list box. |
V |
getCheckedItem() |
|
int |
getCheckedItemIndex() |
|
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) |
This method will see if an item, addressed by index, is the currently selected item in this
RadioCheckBoxList
|
Boolean |
isChecked(V object) |
This method will see if an object is the currently selected item in this RadioCheckBoxList
|
V |
removeItem(int index) |
Removes an item from the list box by its index.
|
RadioBoxList<V> |
removeListener(RadioBoxList.Listener listener) |
Removes a listener from this
RadioBoxList so that if it had been added earlier, it will no longer be
called on user actions |
void |
setCheckedItem(V item) |
Sets the currently checked item by the value itself.
|
void |
setCheckedItemIndex(int index) |
Sets the currently selected item by index.
|
addTo, calculatePreferredSize, draw, getBasePane, getLayoutData, getParent, getPosition, getPreferredSize, getSize, getTextGUI, getTheme, getThemeDefinition, hasParent, invalidate, isInside, isInvalid, onAdded, onAfterDrawing, onBeforeDrawing, onRemoved, runOnGUIThreadIfExistsOtherwiseRunDirect, self, setLayoutData, setPosition, setPreferredSize, setRenderer, setSize, setTheme, toBasePane, toGlobal, withBorder
afterLeaveFocus, getCursorLocation, getInputFilter, getRenderer, handleInput, isEnabled, isFocused, onEnterFocus, onLeaveFocus, setEnabled, setInputFilter, takeFocus
addItem, afterEnterFocus, createDefaultRenderer, getItemAt, getItemCount, getItems, getSelectedIndex, getSelectedItem, indexOf, isEmpty, isFocusable, setListItemRenderer, setSelectedIndex
addTo, getBasePane, getLayoutData, getParent, getPosition, getPreferredSize, getSize, getTextGUI, getTheme, getThemeDefinition, hasParent, invalidate, isInside, onAdded, onRemoved, setLayoutData, setPosition, setPreferredSize, setSize, setTheme, toBasePane, toGlobal, withBorder
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
draw, isInvalid
public RadioBoxList()
RadioBoxList
will be as big as is required
to display all items.public RadioBoxList(TerminalSize preferredSize)
RadioBoxList
cannot fit in the
size specified, scrollbars will be usedpreferredSize
- Size of the RadioBoxList
or null
to have it try to be as big as necessary to
be able to draw all itemsprotected AbstractListBox.ListItemRenderer<V,RadioBoxList<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,RadioBoxList<V>>
ListItemRenderer
to use when drawing the items in the listpublic 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,RadioBoxList<V>>
keyStroke
- What input was entered by the userpublic V removeItem(int index)
AbstractListBox
removeItem
in class AbstractListBox<V,RadioBoxList<V>>
index
- Index of the item to removepublic RadioBoxList<V> clearItems()
AbstractListBox
clearItems
in class AbstractListBox<V,RadioBoxList<V>>
public Boolean isChecked(V object)
object
- Object to test if it's the selected onetrue
if the supplied object is what's currently selected in the list box,
false
otherwise. Returns null if the supplied object is not an item in the list box.public boolean isChecked(int index)
index
- Index of the item to check if it's currently selectedtrue
if the currently selected object is at the supplied index,
false
otherwise. Returns false if the index is out of range.public void setCheckedItem(V item)
item
- Item to be checkedpublic void setCheckedItemIndex(int index)
index
- Index of the item to be selectedpublic int getCheckedItemIndex()
public V getCheckedItem()
public void clearSelection()
public RadioBoxList<V> addListener(RadioBoxList.Listener listener)
RadioBoxList
that will be called on certain user actionslistener
- Listener to attach to this RadioBoxList
public RadioBoxList<V> removeListener(RadioBoxList.Listener listener)
RadioBoxList
so that if it had been added earlier, it will no longer be
called on user actionslistener
- Listener to remove from this RadioBoxList
Copyright © 2020. All rights reserved.