Class JMGenericTextField<T>

Type Parameters:
T - the type of the model object
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable, SwingConstants
Direct Known Subclasses:
JMBigDecimalTextField, JMBigIntegerTextField, JMIntegerTextField, JMStringTextField

public abstract class JMGenericTextField<T> extends JTextField
The abstract class JMGenericTextField provides a text field component that is associated with a model.
See Also:
  • Constructor Details

    • JMGenericTextField

      public JMGenericTextField(@NonNull @NonNull io.github.astrapi69.model.api.IModel<T> propertyModel)
      Constructs a new TextField with the specified property model.
      Parameters:
      propertyModel - the text model to be displayed
    • JMGenericTextField

      public JMGenericTextField()
      Constructs a new TextField. A default model is created, the initial string is null, and the number of columns is set to 0.
    • JMGenericTextField

      public JMGenericTextField(String text)
      Constructs a new TextField initialized with the specified text. A default model is created and the number of columns is 0.
      Parameters:
      text - the text to be displayed, or null
    • JMGenericTextField

      public JMGenericTextField(String text, int columns)
      Constructs a new TextField initialized with the specified text and columns.
      Parameters:
      text - the text to be displayed, or null
      columns - the number of columns to use to calculate the preferred width
    • JMGenericTextField

      public JMGenericTextField(int columns)
      Constructs a new TextField initialized with the specified columns.
      Parameters:
      columns - the number of columns to use to calculate the preferred width
  • Method Details

    • setPropertyModel

      public JMGenericTextField setPropertyModel(@NonNull @NonNull io.github.astrapi69.model.api.IModel<T> propertyModel)
      Sets the property model and updates the text field with the model's text representation.
      Parameters:
      propertyModel - the new property model
      Returns:
      the current instance of JMGenericTextField
    • onInitialize

      protected abstract void onInitialize()
      Called during initialization.
    • toGenericObject

      public abstract T toGenericObject(String text)
      Converts the given text to the generic object type.
      Parameters:
      text - the text to convert
      Returns:
      the converted object of type T
    • toText

      public abstract String toText(T propertyModelObject)
      Converts the given property model object to its text representation.
      Parameters:
      propertyModelObject - the property model object to convert
      Returns:
      the text representation of the property model object