Class TextField<T extends javax.swing.JTextField>
- java.lang.Object
-
- io.github.jonestimd.swing.component.TextField<T>
-
- Type Parameters:
T- the class of the text field
public class TextField<T extends javax.swing.JTextField> extends java.lang.ObjectBuilder for initializing aJTextField.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTextField.ValidatedFactory class for creating aValidatedTextField.
-
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 aJFormattedTextFieldusing the specified format.Tget()TextField<T>inputFilter(java.lang.String pattern)Set theDocumentFilterto filter input using a regex pattern.TextField<T>inputFilter(java.util.function.Predicate<java.lang.String> filter)Set theDocumentFilterto filter input using a predicate.static TextField<javax.swing.JTextField>plain()Create aJTextFieldwith 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.Validatedvalidated(java.util.ResourceBundle bundle, java.lang.String resourcePrefix)Create a factory for initializing a validated text field.
-
-
-
Constructor Detail
-
TextField
public TextField(T textField)
-
-
Method Detail
-
readOnly
public TextField<T> readOnly()
Set the text field to read only.- Returns:
- this
TextFieldfor further configuration
-
rightAligned
public TextField<T> rightAligned()
Set the text field to be right aligned.- Returns:
- this
TextFieldfor further configuration
-
inputFilter
public TextField<T> inputFilter(java.lang.String pattern)
Set theDocumentFilterto filter input using a regex pattern.- Parameters:
pattern- the regex pattern to use for filtering input- Returns:
- this
TextFieldfor further configuration
-
inputFilter
public TextField<T> inputFilter(java.util.function.Predicate<java.lang.String> filter)
Set theDocumentFilterto filter input using a predicate.- Parameters:
filter- the predicate to use for filtering input- Returns:
- this
TextFieldfor further configuration
-
get
public T get()
- Returns:
- the configured text field
-
formatted
public static TextField<javax.swing.JFormattedTextField> formatted(java.text.Format format)
Create aJFormattedTextFieldusing the specified format.- Returns:
- a
TextFieldfor further configuration
-
plain
public static TextField<javax.swing.JTextField> plain()
Create aJTextFieldwith the default configuration.- Returns:
- a
TextFieldfor 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 messagesresourcePrefix- the resource key prefix for validation messages- Returns:
- an instance of
TextField.Validatedfor further configuration.
-
-