Class ShortTextField

java.lang.Object
ca.corbett.forms.fields.FormField
ca.corbett.forms.fields.ShortTextField

public class ShortTextField extends FormField
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
  • Constructor Details

    • ShortTextField

      public ShortTextField(String label, int cols)
      Creates a ShortTextField with the given field label and the given number of columns.
  • Method Details

    • getText

      public String getText()
      Returns the text currently in this field.
      Returns:
      The current text value.
    • setText

      public ShortTextField setText(String text)
      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

      public ShortTextField setAllowBlank(boolean allow)
      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

      public JTextField getTextField()
      Returns the underlying JTextField for this field.
    • addNonBlankValidatorIfNotPresent

      protected void addNonBlankValidatorIfNotPresent()
    • removeNonBlankValidatorIfPresent

      protected void removeNonBlankValidatorIfPresent()