java.lang.Object
is.codion.swing.common.ui.component.text.TextComponents

public final class TextComponents extends Object
A utility class for JTextComponents.
  • Method Details

    • maximumLength

      public static void maximumLength(Document document, int maximumLength)
      Sets the maximum length for the given document, supports SizedDocument and AbstractDocument
      Parameters:
      document - the document
      maximumLength - the maximum string length
    • upperCase

      public static void upperCase(Document document)
      Makes the given document convert all lower case input to upper case, supports SizedDocument and AbstractDocument
      Parameters:
      document - the document
    • lowerCase

      public static void lowerCase(Document document)
      Makes the given document convert all upper case input to lower case, supports SizedDocument and AbstractDocument
      Parameters:
      document - the document
    • selectAllOnFocusGained

      public static <T extends JTextComponent> T selectAllOnFocusGained(T textComponent)
      Selects all text in the given component when it gains focus and clears the selection when focus is lost
      Type Parameters:
      T - the component type
      Parameters:
      textComponent - the text component
      Returns:
      the component
    • selectNoneOnFocusGained

      public static <T extends JTextComponent> T selectNoneOnFocusGained(T textComponent)
      Reverts the functionality added via selectAllOnFocusGained(JTextComponent).
      Type Parameters:
      T - the component type
      Parameters:
      textComponent - the text component
      Returns:
      the text component
      See Also:
    • preferredTextFieldSize

      public static Dimension preferredTextFieldSize()
      Returns:
      the preferred size of a JTextField
    • preferredTextFieldHeight

      public static int preferredTextFieldHeight()
      Returns:
      the preferred height of a JTextField