Class CurrencyTextField

All Implemented Interfaces:
CyclerListener, FocusListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, Scrollable, SwingConstants

public class CurrencyTextField extends DecimalTextField
A currency-aware text field that makes entering currency data easier. This component will format numeric data appropriately for a given Locale, as well perform manipulations on the data as it is input by the user.
See Also:
  • Constructor Details

    • CurrencyTextField

      public CurrencyTextField()
      Constructs a new CurrencyTextField. The number of columns is set to zero and the initial text is set to the zero currency amount for the current Locale.
    • CurrencyTextField

      public CurrencyTextField(int columns)
      Constructs a new CurrencyTextField containing the specified number of columns and the initial text is set to 0.00
      Parameters:
      columns - the number of columns to use to calculate the preferred width.
  • Method Details

    • setCurrencySymbol

      public void setCurrencySymbol(String sym)
      Modifies the currency symbol used in this CurrencyTextField
      Parameters:
      sym - the new currency symbol
    • setGroupSeparator

      public void setGroupSeparator(char sep)
      Modifies the group separator used in this CurrencyTextField
      Parameters:
      sep - the new group separator
    • getCurrencySymbol

      public String getCurrencySymbol()
      Retrieves the currency symbol used in this CurrencyTextField
      Returns:
      the new currency symbol
    • getNumberFormat

      protected NumberFormat getNumberFormat()
      Overrides:
      getNumberFormat in class DecimalTextField
    • formatText

      protected void formatText()
      Overrides:
      formatText in class DecimalTextField
    • setCurrencyFormat

      public void setCurrencyFormat(NumberFormat newFormat)
      Sets the format of the text field.
      Parameters:
      newFormat - the new format
    • setText

      public void setText(String s)
      Description copied from class: DecimalTextField
      Sets the text of this textfield to the specified text, granted the specified text contains numeric data only. If the specified text contains alphabetic characters (including the currency symbol and/or the grouping separator) the text is rejected.
      Overrides:
      setText in class DecimalTextField