public void insertString(int offs, String str, javax.swing.text.AttributeSet a)throws BadLocationException{ 
        boolean flag = true;
        try {
            if (str == null) {// 输入为空，直接返回
                return;
            }
            if((this.getLength() + str.length())>maxLen){
                 super.insertString(offs,str.substring(0,maxLen-this.getLength()),a);
                 return;
            }
            super.insertString(offs,str,a);
        } catch (Exception e) {
            e.printStackTrace();
        }  
  }