Package ca.corbett.forms.fields
Class ShortTextField
java.lang.Object
ca.corbett.forms.fields.FormField
ca.corbett.forms.fields.ShortTextField
A FormField implementation specifically for short (single-line) text input.
The wrapped field is a JTextField. For convenience, a getTextField()
method is provided here to access the JTextField directly, but you can
also access it by calling getFieldComponent() from the FormField class
and casting the result to JTextField.
- Since:
- 2019-11-23
- Author:
- scorbo2
-
Field Summary
Fields inherited from class ca.corbett.forms.fields.FormField
DEFAULT_FONT, defaultFont, extraAttributes, fieldComponent, fieldLabel, fieldValidators, helpLabel, identifier, isEnabled, isVisible, margins, validationLabel, valueChangedListeners -
Constructor Summary
ConstructorsConstructorDescriptionShortTextField(String label, int cols) Creates a ShortTextField with the given field label and the given number of columns. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidgetText()Returns the text currently in this field.Returns the underlying JTextField for this field.booleanReports whether a NonBlankFieldValidator has been added to this TextField.protected voidsetAllowBlank(boolean allow) By default, TextField will allow blank values (empty text) to pass validation.Sets the text in this field.Methods inherited from class ca.corbett.forms.fields.FormField
addAllExtraAttributes, addFieldValidator, addValueChangedListener, clearExtraAttribute, clearExtraAttributes, clearValidationResults, equals, fireValueChangedEvent, getDefaultFont, getExtraAttribute, getFieldComponent, getFieldLabel, getHelpLabel, getHelpText, getIdentifier, getMargins, getValidationLabel, hasFieldLabel, hashCode, hasHelpLabel, hasValidationLabel, isEnabled, isMultiLine, isValid, isVisible, preRender, removeAllFieldValidators, removeFieldValidator, removeValueChangedListener, setAllExtraAttributes, setDefaultFont, setEnabled, setExtraAttribute, setFieldLabelFont, setHelpText, setIdentifier, setMargins, setVisible, shouldExpand, validate
-
Constructor Details
-
ShortTextField
Creates a ShortTextField with the given field label and the given number of columns.
-
-
Method Details
-
getText
Returns the text currently in this field.- Returns:
- The current text value.
-
setText
Sets the text in this field. Will overwrite any previous text. -
isAllowBlank
public boolean isAllowBlank()Reports whether a NonBlankFieldValidator has been added to this TextField. -
setAllowBlank
By default, TextField will allow blank values (empty text) to pass validation. You can disallow that with this method - passing false will add a NonBlankFieldValidator to this TextField. Passing true will remove the NonBlankFieldValidator if one is present. -
getTextField
Returns the underlying JTextField for this field. -
addNonBlankValidatorIfNotPresent
protected void addNonBlankValidatorIfNotPresent() -
removeNonBlankValidatorIfPresent
protected void removeNonBlankValidatorIfPresent()
-