Class PIAPhoneTextField

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

public class PIAPhoneTextField extends JTextField implements KeyListener
Class provides the TextField componenet with the KeyListener to restrict the user not to enter non-numeric value and some special charactes for the phone number field. This field also validates the length or the input with the given maximum length. By default it will allow to enter any number of characters and user can enter only digits 0-9 as an input.
Version:
%version: 1 % %date_created: Fri May 27 2005 %
Author:
Anisha
See Also:
  • Constructor Details

    • PIAPhoneTextField

      public PIAPhoneTextField()
    • PIAPhoneTextField

      public PIAPhoneTextField(int mCol)
    • PIAPhoneTextField

      public PIAPhoneTextField(int mCol, int maxLen)
      User can set the max length for the input.
  • Method Details

    • setMaxLength

      public void setMaxLength(int mMaxLength)
      sets the max. length for the phone input field
      Parameters:
      mMaxLength - - Max length for the phone input
    • getMaxLength

      public int getMaxLength()
      Gives the max. input length
      Returns:
      - int
    • setAllowedChars

      public void setAllowedChars(char[] mAllowedChars)
      sets the allowed characters list
      Parameters:
      mAllowedChars - - list of characters allowed
    • getAllowedChars

      public char[] getAllowedChars()
      Gives array of allowed characters
      Returns:
      - character array of allowed characters
    • keyTyped

      public void keyTyped(KeyEvent ke)
      Allows to enter numeric and some allowed special character which is specified. By default it will allow to enter only 0-9 and space. This method also validates the length of the input if the max. value is specified. Otherwise there is no restriction in for the input length.
      Specified by:
      keyTyped in interface KeyListener
    • keyReleased

      public void keyReleased(KeyEvent ke)
      updates the value of the length for the number of character passed in the input
      Specified by:
      keyReleased in interface KeyListener
    • keyPressed

      public void keyPressed(KeyEvent ke)
      Specified by:
      keyPressed in interface KeyListener