public class Table extends AbstractComponent implements InteractableContainer
Component.Alignment
Constructor and Description |
---|
Table() |
Table(int nrOfColumns) |
Table(int nrOfColumns,
String title) |
Table(String title) |
Modifier and Type | Method and Description |
---|---|
void |
addRow(Component... components)
Adds a new row to this table, using the given components as its cells.
|
void |
addShortcut(char character,
boolean withCtrl,
boolean withAlt,
Action action)
Adds a keyboard shortcut to be invoked when the
Interactable component in focus
within this container didn't handle the keyboard event and the event matches the supplied
character and control key status. |
void |
addShortcut(Key.Kind key,
Action action)
Adds a keyboard shortcut to be invoked when the
Interactable component in focus
within this container didn't handle the keyboard event and the event matches the supplied
Key.Kind . |
void |
alterTableStructure(int nrOfColumns) |
protected TerminalSize |
calculatePreferredSize() |
int |
getNrOfRows() |
Component[] |
getRow(int index) |
String |
getTitle() |
boolean |
hasInteractable(Interactable interactable)
Returns true if this container contains the
interactable passed in as the parameter |
Interactable |
nextFocus(Interactable fromThis)
Given an interactable, find the next one in line to receive focus.
|
Interactable |
previousFocus(Interactable fromThis)
Given an interactable, find the previous one in line to receive focus.
|
void |
removeAllRows()
Removes all rows from this table.
|
void |
removeRow(int index) |
void |
repaint(TextGraphics graphics)
This is the main 'paint' method for a component, it's called when
lanterna wants the component to re-draw itself.
|
void |
setColumnPaddingSize(int size) |
protected void |
setParent(Container container) |
void |
setTitle(String title) |
boolean |
triggerShortcut(Key key)
Looks for a shortcut that matches this
key and, if one is found, executes it. |
addBorder, addComponentListener, getAlignment, getComponentListeners, getGUIScreen, getMinimumSize, getParent, getPreferredSize, getWindow, invalidate, isScrollable, isVisible, removeComponentListener, setAlignment, setPreferredSize, setVisible, transformAccordingToAlignment
public Table()
public Table(String title)
public Table(int nrOfColumns)
public Table(int nrOfColumns, String title)
public void setColumnPaddingSize(int size)
public void addRow(Component... components)
public int getNrOfRows()
public Component[] getRow(int index)
public void removeRow(int index)
public final void alterTableStructure(int nrOfColumns)
public void removeAllRows()
protected TerminalSize calculatePreferredSize()
calculatePreferredSize
in class AbstractComponent
public void repaint(TextGraphics graphics)
Component
protected void setParent(Container container)
setParent
in class AbstractComponent
public boolean hasInteractable(Interactable interactable)
InteractableContainer
interactable
passed in as the parameterhasInteractable
in interface InteractableContainer
interactable
- interactable
to look fortrue
if the container has interactable
, otherwise false
public Interactable nextFocus(Interactable fromThis)
InteractableContainer
nextFocus
in interface InteractableContainer
fromThis
- Component from which to get the next interactable, or if
null, pick the first available interactablepublic Interactable previousFocus(Interactable fromThis)
InteractableContainer
previousFocus
in interface InteractableContainer
fromThis
- Component from which to get the previous interactable,
or if null, pick the last interactable in the listpublic void addShortcut(Key.Kind key, Action action)
InteractableContainer
Interactable
component in focus
within this container didn't handle the keyboard event and the event matches the supplied
Key.Kind
. Please note that calling addShortcut
with
Key.Kind.NormalKey
will throw IllegalArgumentException
; if you want to add
a keyboard shortcut for a non-special key, please use
addShortcut(char, boolean, boolean, Action)
.addShortcut
in interface InteractableContainer
key
- Kind of key to trigger the shortcutaction
- Action to run, on the event thread, when the shortcut is triggeredpublic void addShortcut(char character, boolean withCtrl, boolean withAlt, Action action)
InteractableContainer
Interactable
component in focus
within this container didn't handle the keyboard event and the event matches the supplied
character and control key status. If you want to add a keyboard shortcut for a special keys,
please use addShortcut(Key.Kind, Action)
.addShortcut
in interface InteractableContainer
character
- Character types on the keyboard to trigger the shortcutwithCtrl
- If true
, ctrl key must be down when the key is typed to trigger;
if false
the ctrl key must be up to triggerwithAlt
- If true
, alt key must be down when the key is typed to trigger;
if false
the alt key must be up to triggeraction
- Action to run, on the event thread, when the shortcut is triggeredpublic boolean triggerShortcut(Key key)
InteractableContainer
key
and, if one is found, executes it.triggerShortcut
in interface InteractableContainer
key
- Key
to check for matching shortcutstrue
if a shortcut was triggered and executed, false
otherwise.public String getTitle()
public void setTitle(String title)
Copyright © 2015. All Rights Reserved.