Class TextField<T extends javax.swing.JTextField>

  • Type Parameters:
    T - the class of the text field

    public class TextField<T extends javax.swing.JTextField>
    extends java.lang.Object
    Builder for initializing a JTextField.
    • Constructor Summary

      Constructors 
      Constructor Description
      TextField​(T textField)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static TextField<javax.swing.JFormattedTextField> formatted​(java.text.Format format)
      Create a JFormattedTextField using the specified format.
      T get()  
      TextField<T> inputFilter​(java.lang.String pattern)
      Set the DocumentFilter to filter input using a regex pattern.
      TextField<T> inputFilter​(java.util.function.Predicate<java.lang.String> filter)
      Set the DocumentFilter to filter input using a predicate.
      static TextField<javax.swing.JTextField> plain()
      Create a JTextField with the default configuration.
      TextField<T> readOnly()
      Set the text field to read only.
      TextField<T> rightAligned()
      Set the text field to be right aligned.
      static TextField.Validated validated​(java.util.ResourceBundle bundle, java.lang.String resourcePrefix)
      Create a factory for initializing a validated text field.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TextField

        public TextField​(T textField)
    • Method Detail

      • readOnly

        public TextField<T> readOnly()
        Set the text field to read only.
        Returns:
        this TextField for further configuration
      • rightAligned

        public TextField<T> rightAligned()
        Set the text field to be right aligned.
        Returns:
        this TextField for further configuration
      • inputFilter

        public TextField<T> inputFilter​(java.lang.String pattern)
        Set the DocumentFilter to filter input using a regex pattern.
        Parameters:
        pattern - the regex pattern to use for filtering input
        Returns:
        this TextField for further configuration
      • inputFilter

        public TextField<T> inputFilter​(java.util.function.Predicate<java.lang.String> filter)
        Set the DocumentFilter to filter input using a predicate.
        Parameters:
        filter - the predicate to use for filtering input
        Returns:
        this TextField for further configuration
      • get

        public T get()
        Returns:
        the configured text field
      • formatted

        public static TextField<javax.swing.JFormattedTextField> formatted​(java.text.Format format)
        Create a JFormattedTextField using the specified format.
        Returns:
        a TextField for further configuration
      • plain

        public static TextField<javax.swing.JTextField> plain()
        Create a JTextField with the default configuration.
        Returns:
        a TextField for further configuration
      • validated

        public static TextField.Validated validated​(java.util.ResourceBundle bundle,
                                                    java.lang.String resourcePrefix)
        Create a factory for initializing a validated text field.
        Parameters:
        bundle - the resource bundle for validation messages
        resourcePrefix - the resource key prefix for validation messages
        Returns:
        an instance of TextField.Validated for further configuration.