Class DoubleInputTextField

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable, SwingConstants

public class DoubleInputTextField extends JTextField
This is an input formatted text field for a double value. This text field will have the special alert background color is the changes are not committed. After posting changes the background color will be normal color again. In addition to usual JTextField methods it provides getValue() and setValue(double val) methods to get and to set double value to this container. User has to add one or several ActionListeners as usual to interact with the external code. By default the format of this text field is ###.###. To specify another format the method setNumberFormat should be used.
See Also:
  • Constructor Details

    • DoubleInputTextField

      public DoubleInputTextField()
      Creates new DoubleInputTextField
    • DoubleInputTextField

      public DoubleInputTextField(int col)
      Creates new DoubleInputTextField with predefined number of columns
    • DoubleInputTextField

      public DoubleInputTextField(String text)
      Creates new DoubleInputTextField with predefined text
    • DoubleInputTextField

      public DoubleInputTextField(String text, int col)
      Creates new DoubleInputTextField with predefined text and number of columns
    • DoubleInputTextField

      public DoubleInputTextField(double valIn, NumberFormat formatIn, int col)
      Creates new DoubleInputTextField with predefined value, format, and number of columns
  • Method Details

    • getValue

      public double getValue()
      Returns the value
    • getIntValue

      public int getIntValue()
      Returns the integer value
    • setValue

      public double setValue(double valIn)
      Sets the value
    • setValue

      public int setValue(int valIn)
      Sets the integer value
    • setValueQuietly

      public double setValueQuietly(double valIn)
      Sets the value quietly. The external listeners do not receive the "action performed" call.
    • setDecimalFormat

      @Deprecated public void setDecimalFormat(DecimalFormat formatIn)
      Deprecated.
      use setNumberFormat() instead as constraining to DecimalFormat is not necessary and there should be no expectation that the internal number format is a DecimalFormat. This method is around temporarily for backward compatibility but will be removed in the near future. Set the number format
    • setNumberFormat

      public void setNumberFormat(NumberFormat formatIn)
      Sets the format
    • getNumberFormat

      public NumberFormat getNumberFormat()
      Returns the format
    • setValueQuietly

      public int setValueQuietly(int valIn)
      Sets the integer value quietly. The external listeners do not receive the "action performed" call.
    • setAlertBackground

      public void setAlertBackground(Color alertColor)
      Sets the alert background color
    • setNormalBackground

      public void setNormalBackground(Color normalColor)
      Sets the normal background color
    • fireActionPerformed

      protected void fireActionPerformed()
      Fires ActionPerformed method of superclass
      Overrides:
      fireActionPerformed in class JTextField
    • setDocument

      public void setDocument(Document doc)
      Overrides setDocument method of superclass to keep existing document listener
      Overrides:
      setDocument in class JTextField
    • removeInnerFocusListener

      public void removeInnerFocusListener()
      Remove inner FocusListener
    • restoreInnerFocusListener

      public void restoreInnerFocusListener()
      Restore inner FocusListener