Class ImmediateTextField<T>

java.lang.Object
PamView.dialog.smart.ImmediateTextField<T>

public abstract class ImmediateTextField<T> extends Object
Text field which can immediately respond to text being entered and update a corresponding value in a PAMGurd control structure. Will call abstract function valueChange whenever the control is typed in, enter is hit or the focus of the control is lost. Concrete implementations can then update parameters accordingly.

Should be able to handle Double, Integer and String types. To add others, just need to add more options to the getValue() function.

Author:
Doug Gillespie.
  • Constructor Details

    • ImmediateTextField

      public ImmediateTextField(Class<T> fieldClass, int fieldLength, String prefix, String suffix, boolean colourManaged)
      Construct text field that calls back whenever the value is changed.
      Parameters:
      fieldClass - data class (Double, Integer or String) must match the template class
      fieldLength - field length (characters)
      prefix - optional text prefix to display
      suffix - optional text suffix to display
      colourManaged - Manage day / night colours using standard themes.
  • Method Details

    • setValue

      public void setValue(T value)
    • setToolTipText

      public void setToolTipText(String tip, boolean preandpost)
    • getPrefix

      public String getPrefix()
      Returns:
      the prefix
    • setPrefix

      public void setPrefix(String prefix)
      Parameters:
      prefix - the prefix to set
    • getSuffix

      public String getSuffix()
      Returns:
      the suffix
    • setSuffix

      public void setSuffix(String suffix)
      Parameters:
      suffix - the suffix to set
    • getNumberFormat

      public NumberFormat getNumberFormat()
      Returns:
      the numberFormat
    • setNumberFormat

      public void setNumberFormat(NumberFormat numberFormat)
      Parameters:
      numberFormat - the numberFormat to set
    • getTextField

      public JTextField getTextField()
      Returns:
      the textField
    • getPreLabel

      public JLabel getPreLabel()
      Returns:
      the preLabel
    • getPostLabel

      public JLabel getPostLabel()
      Returns:
      the postLabel
    • valueChange

      public abstract void valueChange(T newValue, boolean valueError, boolean lostFocus)
      Called whenever the value changes and also when the keyboard focus leaves the control. Some users may want to respond to every key stroke, others only when the keyboard focus leaves the control.
      Parameters:
      newValue - value in text field. Will be null if valueError
      valueError - error in value, e.g. if number is invalid
      lostFocus - focus has moved from the control or enter has been pressed.
    • addToParent

      public void addToParent(JComponent parent, GridBagConstraints c)
      Add the components to the parent component. By default, components will be laid out with an increment of the x value in the gridbag constraints of one per non null component. If you require different bahaviour, get the components individually and do as you like.
      Parameters:
      parent - Parent component
      c - gridbag constraints with correct start position for first non null component.