Class IntegerInputTextField

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

public class IntegerInputTextField extends JTextField
This is an input formatted text field for an integer 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(int val) methods to get and to set integer 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 setDecimalFormat should be used.
See Also:
  • Constructor Details

    • IntegerInputTextField

      public IntegerInputTextField()
      Creates new IntegerInputTextField
    • IntegerInputTextField

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

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

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

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

    • getValue

      public int getValue()
      Returns the value
    • getDecimalFormat

      public DecimalFormat getDecimalFormat()
      Returns the number formatter currently used by the input field.
      Returns:
      decimal number formatter
      Since:
      Jan 5, 2010
    • getAlertColor

      public Color getAlertColor()
      Return the background color used when alerting the user.
      Returns:
      text field alert background color
      Since:
      Jan 5, 2010
    • getNormalColor

      public Color getNormalColor()
      Return the normal background color of the text field.
      Returns:
      background color of the text field
      Since:
      Jan 5, 2010
    • setValue

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

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

      public void setDecimalFormat(DecimalFormat formatIn)
      Sets the format
    • 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