@Override
    public void replace(
        final DocumentFilter.FilterBypass fb,
        final int offset,
        final int length,
        final String string,
        final AttributeSet attr)
        throws BadLocationException {
      if (isValid(string, length)) {
        super.replace(fb, offset, length, string, attr);
      }
    }
Filter for JFormattedTextField. Ensures valid filenames. Does not work for directories.

@param directory Directory where a file with the specified filename is temporarily created for
    validation purpose. http://stackoverflow.com/questions/893977/java-how-to-find-out-whether
    -a-file-name-is-valid
java/zylib/src/main/java/com/google/security/zynamics/zylib/gui/CFilenameFormatter.java