public class TextBox extends AbstractInteractableComponent
Interactable.FocusChangeDirection, Interactable.Result
Component.Alignment
Constructor and Description |
---|
TextBox()
Creates a text box component, where the user can enter text by typing on
the keyboard.
|
TextBox(String initialContent)
Creates a text box component, where the user can enter text by typing on
the keyboard.
|
TextBox(String initialContent,
int width)
Creates a text box component, where the user can enter text by typing on
the keyboard.
|
Modifier and Type | Method and Description |
---|---|
protected TerminalSize |
calculatePreferredSize() |
int |
getEditPosition() |
char |
getFillCharacter() |
String |
getText() |
Interactable.Result |
keyboardInteraction(Key key)
This method is called when this component has focus and the user has
pressed a key on the keyboard.
|
protected String |
prerenderTransformation(String textboxString) |
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 |
setEditPosition(int editPosition) |
void |
setFillCharacter(char fillCharacter) |
void |
setText(String text) |
afterEnteredFocus, afterLeftFocus, getHotspot, hasFocus, onEnterFocus, onLeaveFocus, setHotspot
addBorder, addComponentListener, getAlignment, getComponentListeners, getGUIScreen, getMinimumSize, getParent, getPreferredSize, getWindow, invalidate, isScrollable, isVisible, removeComponentListener, setAlignment, setParent, setPreferredSize, setVisible, transformAccordingToAlignment
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addBorder, addComponentListener, getAlignment, getMinimumSize, getParent, getPreferredSize, getWindow, isScrollable, isVisible, removeComponentListener, setAlignment, setPreferredSize, setVisible
public TextBox()
public TextBox(String initialContent)
initialContent
- Initial text content of the text boxpublic TextBox(String initialContent, int width)
initialContent
- Initial text content of the text boxwidth
- Width, in columns, of the text box. Set to 0 if you
want to autodetect the width based on initial content (will be set to
10 columns in width at minimum)public String getText()
public void setText(String text)
public void setEditPosition(int editPosition)
public int getEditPosition()
public char getFillCharacter()
public void setFillCharacter(char fillCharacter)
public void repaint(TextGraphics graphics)
Component
graphics
- TextGraphics object to use for drawing the component and
getting information about the drawing contextprotected TerminalSize calculatePreferredSize()
calculatePreferredSize
in class AbstractComponent
public Interactable.Result keyboardInteraction(Key key)
Interactable
key
- Key pressed on the keyboardCopyright © 2015. All Rights Reserved.