@Override
    public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
      StringBuilder sb = null;
      for (int i = 0; i < str.length(); i++) {
        char c = str.charAt(i);
        boolean replace = c == '\\' || c == '/' || SystemInfo.isWindows && (c == '|' || c == ':');
        if (replace) {
          if (sb == null) {
            sb = new StringBuilder(str.length());
            sb.append(str, 0, i);
          }
          sb.append('_');
        }
        else if (sb != null) {
          sb.append(c);
        }
      }
      if (sb != null) {
        str = sb.toString();
      }
      super.insertString(offs, str, a);
    }
@Override
    public void insertString(int offs, String str, AttributeSet a)