public void insertChars(String c){
  String currentText=getText();
  if (!validChar(c)) {
    return;
  }
  int pos=getCursorPosition() + 1;
  if (overwriteMode && pos <= currentText.length()) {
    setText(currentText.substring(0,pos - 1) + c + currentText.substring(pos,currentText.length()));
  }
 else {
    if (currentText.length() + c.length() > getMaxSize()) {
      return;
    }
    setText(currentText.substring(0,pos - 1) + c + currentText.substring(pos - 1,currentText.length()));
  }
  if (c.length() > 1) {
    pos+=c.length() - 1;
    setCursorPosition(pos);
    return;
  }
  increaseCursor();
}

public void insertChars ( String c ) { String currentText = getText ( ) ; if ( ! validChar ( c ) ) { return ; } int pos = getCursorPosition ( ) + 1 ; if ( overwriteMode && pos <= currentText . length ( ) ) { setText ( currentText . substring ( 0 , pos - 1 ) + c + currentText . substring ( pos , currentText . length ( ) ) ) ; } else { if ( currentText . length ( ) + c . length ( ) > getMaxSize ( ) ) { return ; } setText ( currentText . substring ( 0 , pos - 1 ) + c + currentText . substring ( pos - 1 , currentText . length ( ) ) ) ; } if ( c . length ( ) > 1 ) { pos += c . length ( ) - 1 ; setCursorPosition ( pos ) ; return ; } increaseCursor ( ) ; }
this method is responsible for adding a character into the field and is the focal point for all input . it can be overriden to prevent a particular char from insertion or provide a different behavior for char insertion . it is the responsibility of this method to shift the cursor and invoke settext . . . < p > this method accepts a string for the more elaborate cases such as multi - char input and paste .
