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.Object
Builder for initializing aJTextField
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TextField.Validated
Factory 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 aJFormattedTextField
using the specified format.T
get()
TextField<T>
inputFilter(java.lang.String pattern)
Set theDocumentFilter
to filter input using a regex pattern.TextField<T>
inputFilter(java.util.function.Predicate<java.lang.String> filter)
Set theDocumentFilter
to filter input using a predicate.static TextField<javax.swing.JTextField>
plain()
Create aJTextField
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.
-
-
-
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 theDocumentFilter
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 theDocumentFilter
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 aJFormattedTextField
using the specified format.- Returns:
- a
TextField
for further configuration
-
plain
public static TextField<javax.swing.JTextField> plain()
Create aJTextField
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 messagesresourcePrefix
- the resource key prefix for validation messages- Returns:
- an instance of
TextField.Validated
for further configuration.
-
-