Class ParsableValuePanel<T>

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, TextFieldVerifierImp
Direct Known Subclasses:
ByteValuePanel, DoubleValuePanel, FloatValuePanel, IntegerValuePanel, LongValuePanel, ShortValuePanel, StringValuePanel

public abstract class ParsableValuePanel<T> extends ValuePanel<T> implements TextFieldVerifierImp
A ParsableValuePanel holds a value that can be parsed from a text string and allows the user to change it.
Since:
3.3.2
Author:
Peter Hollemans
See Also:
  • Constructor Details

    • ParsableValuePanel

      public ParsableValuePanel()
      Creates a new value panel. The initial value is set to zero.
  • Method Details

    • setTextLength

      public void setTextLength(int length)
      Sets the length of the text string.
      Parameters:
      length - the number of characters long that need to be parsed.
    • getInitialValue

      protected abstract T getInitialValue()
      Gets the initial value for this panel.
      Returns:
      the initial value.
    • setValue

      public void setValue(T value)
      Description copied from class: ValuePanel
      Sets the value in this panel. Calling this method does not cause the panel to fire a property change event.
      Specified by:
      setValue in class ValuePanel<T>
      Parameters:
      value - the new object value.
    • getValue

      public T getValue()
      Description copied from class: ValuePanel
      Gets the object value for this panel.
      Specified by:
      getValue in class ValuePanel<T>
      Returns:
      the object value.
    • parseText

      protected abstract T parseText(JTextField field)
      Parses the text in the field to a value.
      Parameters:
      field - the text field to parse.
      Returns:
      the value parsed, or null if there was a number format exception.
    • verifyText

      public boolean verifyText(JTextField field)
      Description copied from interface: TextFieldVerifierImp
      Verifies that the text in the field is valid.
      Specified by:
      verifyText in interface TextFieldVerifierImp
      Parameters:
      field - the text field to check.
      Returns:
      true if the text is valid or false if not.
    • resetText

      public void resetText(JTextField field)
      Description copied from interface: TextFieldVerifierImp
      Resets the text in the field to a valid value.
      Specified by:
      resetText in interface TextFieldVerifierImp
      Parameters:
      field - the text field to check.
    • textChanged

      public void textChanged(JTextField field)
      Description copied from interface: TextFieldVerifierImp
      Handles a change in text in the field.
      Specified by:
      textChanged in interface TextFieldVerifierImp
      Parameters:
      field - the text field to take action on.