@Override
  public void insertString(int offs, String str, AttributeSet a)
      throws BadLocationException {
    if (str == null)
      return;
    
    StringBuilder sb = new StringBuilder();

    if (((getLength() + str.length()) <= limit)) {
        if (test(str)){
            super.insertString(offs, str, a);
        }
        else {
            JOptionPane.showMessageDialog(null, "Apenas numeros podem ser inseridos nesse campo!");
        }
    }
    else{
        JOptionPane.showMessageDialog(null, "Limite de Caracteres: " + limit);
    }
  }