Class WidgetTextBox

java.lang.Object
app.ui.widgets.Widget
app.ui.widgets.WidgetTextBox
All Implemented Interfaces:
IDrawable, ISelectable, ITextInput
Direct Known Subclasses:
WidgetPasswordBox

public class WidgetTextBox extends Widget implements ITextInput, ISelectable
WidgetTextBox represents a text input field in a user interface. It allows for text input and display, and can be selected or unselected.
  • Constructor Details

    • WidgetTextBox

      public WidgetTextBox(int x, int y, int len, String text)
      Constructs a WidgetTextBox with default text alignment to the left.
      Parameters:
      x - The x-coordinate of the widget.
      y - The y-coordinate of the widget.
      len - The length of the widget.
      text - The initial text of the widget.
    • WidgetTextBox

      public WidgetTextBox(int x, int y, int len, String text, TEXT_ALIGNMENT textAlignment)
      Constructs a WidgetTextBox with specified text alignment.
      Parameters:
      x - The x-coordinate of the widget.
      y - The y-coordinate of the widget.
      len - The length of the widget.
      text - The initial text of the widget.
      textAlignment - The alignment of the text within the widget.
  • Method Details

    • drawSelection

      public void drawSelection(char[][] buffer, com.googlecode.lanterna.TextColor[][] printColor, com.googlecode.lanterna.TextColor[][] backColor)
      Constructs a WidgetTextBox with default text alignment to the left.
      Specified by:
      drawSelection in interface ISelectable
      Parameters:
      buffer - The buffer to draw the widget to.
      printColor - The color of the text.
      backColor - The color of the background.
    • select

      public void select()
      Selects the widget.
      Specified by:
      select in interface ISelectable
    • unselect

      public void unselect()
      Unselects the widget.
      Specified by:
      unselect in interface ISelectable
    • draw

      public void draw(char[][] buffer, com.googlecode.lanterna.TextColor[][] printColor, com.googlecode.lanterna.TextColor[][] backColor)
      draws the widget to the buffer.
      Specified by:
      draw in interface IDrawable
      Specified by:
      draw in class Widget
      Parameters:
      buffer - The buffer to draw the widget to.
      printColor - The color of the text.
      backColor - The color of the background.
    • keyStroke

      public void keyStroke(com.googlecode.lanterna.input.KeyStroke keyStroke)
      keyStroke processes a key stroke.
      Specified by:
      keyStroke in interface ITextInput
      Parameters:
      keyStroke - The key stroke to process.