All Implemented Interfaces:
GUIElement, KeyPressedHandler, ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
GUICommandText, GUIQueryText, GUITextField

public abstract class GUIText extends ActivatableGUIElement implements KeyPressedHandler
Abstract base class for text input fields. It allows entering and editing text. Subclasses define the behavior when execute(String) executing the entered text when ENTER is pressed.
See Also:
  • Constructor Details

    • GUIText

      protected GUIText(@NotNull @NotNull CommandCallback commandCallback, @Nullable @Nullable CommandHistory commandHistory, @NotNull @NotNull TooltipManager tooltipManager, @NotNull @NotNull GUIElementListener elementListener, @NotNull @NotNull String name, @NotNull @NotNull NewCharModel newCharModel, @NotNull @NotNull Image activeImage, @NotNull @NotNull Image inactiveImage, @NotNull @NotNull Font font, @NotNull @NotNull Color inactiveColor, @NotNull @NotNull Color activeColor, int margin, @NotNull @NotNull String text, @NotNull @NotNull GuiFactory guiFactory)
      Creates a new instance.
      Parameters:
      commandCallback - the command callback to use
      commandHistory - the command history to use or null to disable command history access
      tooltipManager - the tooltip manager to update
      elementListener - the element listener to notify
      name - the name of this element
      newCharModel - the new char model to show
      activeImage - the element's background image when it is active
      inactiveImage - the element's background image when it is inactive
      font - the font for rendering displayed text
      inactiveColor - the color for rendering displayed text when the element is active; also cursor color
      activeColor - the color for rendering displayed text when the element is active
      margin - the left margin in pixels
      text - the initially entered text
      guiFactory - the global GUI factory instance
  • Method Details

    • setText

      public void setText(@NotNull @NotNull String text)
      Sets the entered text.
      Parameters:
      text - the text
    • getText

      @NotNull public @NotNull String getText()
      Returns the entered text.
      Returns:
      the text
    • paintComponent

      public void paintComponent(@NotNull @NotNull Graphics g)
      Overrides:
      paintComponent in class JComponent
    • getPreferredSize

      @NotNull public @NotNull Dimension getPreferredSize()
      Overrides:
      getPreferredSize in class JComponent
    • getMinimumSize

      @NotNull public @NotNull Dimension getMinimumSize()
      Overrides:
      getMinimumSize in class JComponent
    • getMaximumSize

      @NotNull public @NotNull Dimension getMaximumSize()
      Overrides:
      getMaximumSize in class JComponent
    • mouseClicked

      public void mouseClicked(@NotNull @NotNull MouseEvent e)
      Description copied from interface: GUIElement
      Will be called when the user has clicked (pressed+released) this element. This event will be delivered after GUIElement.mouseReleased(MouseEvent).
      Specified by:
      mouseClicked in interface GUIElement
      Overrides:
      mouseClicked in class AbstractGUIElement
      Parameters:
      e - the mouse event relative to this element
    • activeChanged

      protected void activeChanged()
      Description copied from class: ActivatableGUIElement
      Will be called whenever the active state has changed.
      Specified by:
      activeChanged in class ActivatableGUIElement
    • keyPressed

      public boolean keyPressed(@NotNull @NotNull KeyEvent2 e)
      Description copied from interface: KeyPressedHandler
      Invoked when a key has been pressed.
      Specified by:
      keyPressed in interface KeyPressedHandler
      Parameters:
      e - the key event for the key
      Returns:
      whether the key event has been consumed
    • execute

      protected abstract void execute(@NotNull @NotNull String command)
      Will be called to execute the entered command.
      Parameters:
      command - the entered command
    • setHideInput

      public void setHideInput(boolean hideInput)
      Enables or disables hidden text.
      Parameters:
      hideInput - if set, hide input; else show input