Class TextBox.DefaultTextBoxRenderer

  • All Implemented Interfaces:
    ComponentRenderer<TextBox>, InteractableRenderer<TextBox>, TextBox.TextBoxRenderer
    Enclosing class:
    TextBox

    public static class TextBox.DefaultTextBoxRenderer
    extends java.lang.Object
    implements TextBox.TextBoxRenderer
    This is the default text box renderer that is used if you don't override anything. With this renderer, the text box is filled with a solid background color and the text is drawn on top of it. Scrollbars are added for multi-line text whenever the text inside the TextBox does not fit in the available area.
    • Field Detail

      • verticalScrollBar

        private final ScrollBar verticalScrollBar
      • horizontalScrollBar

        private final ScrollBar horizontalScrollBar
      • hideScrollBars

        private boolean hideScrollBars
      • unusedSpaceCharacter

        private java.lang.Character unusedSpaceCharacter
    • Constructor Detail

      • DefaultTextBoxRenderer

        public DefaultTextBoxRenderer()
        Default constructor
    • Method Detail

      • setUnusedSpaceCharacter

        public void setUnusedSpaceCharacter​(char unusedSpaceCharacter)
        Sets the character to represent an empty untyped space in the text box. This will be an empty space by default but you can override it to anything that isn't double-width.
        Parameters:
        unusedSpaceCharacter - Character to draw in unused space of the TextBox
        Throws:
        java.lang.IllegalArgumentException - If unusedSpaceCharacter is a double-width character
      • getPreferredSize

        public TerminalSize getPreferredSize​(TextBox component)
        Description copied from interface: ComponentRenderer
        Given the supplied component, how large does this renderer want the component to be? Notice that this is the responsibility of the renderer and not the component itself, since the component has no idea what its visual representation looks like.
        Specified by:
        getPreferredSize in interface ComponentRenderer<TextBox>
        Parameters:
        component - Component to calculate the preferred size of
        Returns:
        The size this renderer would like the component to take up
      • setHideScrollBars

        public void setHideScrollBars​(boolean hideScrollBars)
        Controls whether scrollbars should be visible or not when a multi-line TextBox has more content than it can draw in the area it was assigned (default: false)
        Parameters:
        hideScrollBars - If true, don't show scrollbars if the multi-line content is bigger than the area