javax.swing.filechooser.FileFilter.accept()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(136)

本文整理了Java中javax.swing.filechooser.FileFilter.accept()方法的一些代码示例,展示了FileFilter.accept()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileFilter.accept()方法的具体详情如下:
包路径:javax.swing.filechooser.FileFilter
类名称:FileFilter
方法名:accept

FileFilter.accept介绍

暂无

代码示例

代码示例来源:origin: openmicroscopy/bioformats

/** Accepts files with the proper filename prefix. */
@Override
public boolean accept(File f) {
 for (int i=0; i<filts.length; i++) {
  if (filts[i].accept(f)) return true;
 }
 return false;
}

代码示例来源:origin: EvoSuite/evosuite

public boolean accept(File f) {
  boolean shown = true;
  if(f != null && fileFilter != null) {
    shown = fileFilter.accept(f);
  }
  return shown;
}

代码示例来源:origin: nl.cloudfarming.client/sensor-api

@Override
public boolean accept(File pathname) {
  for (FileFilter filter : filters) {
    if (filter.accept(pathname)) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: ome/formats-bsd

/** Accepts files with the proper filename prefix. */
@Override
public boolean accept(File f) {
 for (int i=0; i<filts.length; i++) {
  if (filts[i].accept(f)) return true;
 }
 return false;
}

代码示例来源:origin: scifio/scifio

/** Accepts files with the proper filename prefix. */
@Override
public boolean accept(final File file) {
  for (final FileFilter filter : fileFilters) {
    if (filter.accept(file)) return true;
  }
  return false;
}

代码示例来源:origin: io.scif/scifio

/** Accepts files with the proper filename prefix. */
@Override
public boolean accept(final File file) {
  for (final FileFilter filter : fileFilters) {
    if (filter.accept(file)) return true;
  }
  return false;
}

代码示例来源:origin: datacleaner/DataCleaner

@Override
public boolean accept(final File f) {
  for (final FileFilter fileFilter : fileFilters) {
    if (fileFilter.accept(f)) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: org.orbisgis/orbisgis-view

@Override
public boolean accept(File file) {
  return fileFilter.accept(file);
}

代码示例来源:origin: sc.fiji/FS_Align_TrakEM2

public boolean accept(File file) {
    return javaxFileFilter.accept(file);
  }
}

代码示例来源:origin: edu.toronto.cs.savant/savant-core

@Override
  public boolean accept(File dir, String name) {
    return filter.accept(new File(dir, name));
  }
}

代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client

@Override
  public boolean accept(File dir, String name) {
    return filter.accept(new File(dir, name));
  }
}

代码示例来源:origin: eu.mihosoft.vrl/vrl

/**
 * Indicates whether the given file has a supported file extension, i.e., if
 * the file filter contains the extension.
 *
 * @param file the file to check
 * @param filter the file extension filter
 * @return <code>true</code> if the extension is supported;
 * <code>false</code> ozherwise
 */
private boolean hasSupportedExtension(File file, FileFilter filter) {
  return filter.accept(file) && !file.isDirectory();
}

代码示例来源:origin: jawi/ols

/**
 * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)
 */
@Override
public boolean accept( final File aDir, final String aName )
{
 final File fileName = new File( aDir, aName );
 for ( FileFilter filter : this.fileFilters )
 {
  if ( filter.accept( fileName ) )
  {
   return true;
  }
 }
 return false;
}

代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client

private void addFileToImport(File f) {
  if (!fileFilter.accept(f)) {
    DialogUtils.displayMessage(String.format("File %s does not appear to be in the correct format", f.getName()));
    return;
  }
  if (filesToImport.contains(f)) {
    DialogUtils.displayMessage(String.format("File %s already listed for import", f.getName()));
    return;
  }
  filesToImport.add(f);
}

代码示例来源:origin: openstreetmap/osmembrane

/**
   * Returns the a corresponding filetype for a given filename.
   * 
   * @param file
   *            filename for which the filetype is needed.
   * 
   * @return filetype if a matching one is found, otherwise NULL
   */
  public static FileType fileTypeFor(File file) {
    for (FileType fileType : autoselectableFileTypes) {
      if (fileType.getFileFilter().accept((file)) && fileType != ALLTYPES) {
        return fileType;
      }
    }
    return null;
  }
}

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public LinkedList<Figure> construct() throws Exception {
  for (File file : files) {
    FileFormatLoop:
    for (InputFormat format : drawing.getInputFormats()) {
      if (file.isFile()
          && format.getFileFilter().accept(file)) {
        if (DEBUG) {
          System.out.println("DefaultDrawingViewTransferHandler  importing file " + file);
        }
        format.read(file.toURI(), drawing, false);
      }
    }
  }
  return new LinkedList<Figure>(drawing.getChildren());
}

代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler

public int showOpenDialog(Component parent) {
  int status = super.showOpenDialog(parent);
  if (status != JFileChooser.APPROVE_OPTION) {
    cachedDialog = null;
    return status;
  }
  // make sure invalid directory is not selected
  File file = this.getSelectedFile();
  if (selectFilter.accept(file)) {
    cachedDialog = null;
    return JFileChooser.APPROVE_OPTION;
  }
  else {
    if (file.isDirectory()) {
      this.setCurrentDirectory(file);
    }
    return this.showOpenDialog(parent);
  }
}

代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler

@SuppressWarnings("unchecked")
private boolean processDropAction(Transferable transferable) {
  List<File> fileList;
  try {
    fileList = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
  } catch (Exception e) {
    return false;
  }
  if (fileList != null) {
  File transferFile = fileList.get(0);
    if (transferFile.isFile()) {
      FileFilter filter = FileFilters.getApplicationFilter();
      if (filter.accept(transferFile)) {
        ActionEvent e = new ActionEvent(transferFile, ActionEvent.ACTION_PERFORMED, "OpenProject");
        Application.getInstance().getActionManager().getAction(OpenProjectAction.class).actionPerformed(e);
        return true;
      }
    }
  }
  return false;
}

代码示例来源:origin: net.anwiba.commons/anwiba-commons-swing-core

@Override
 public IValidationResult validate(final String value) {
  if (StringUtilities.isNullOrEmpty(value)) {
   return IValidationResult.valid();
  }
  if (!isValid(value)) {
   return IValidationResult.inValid(FileChooserMessages.InvalidFileName);
  }
  final File file = new File(value);
  if (!file.isFile()) {
   return IValidationResult.inValid(FileChooserMessages.InvalidFileName);
  }
  boolean flag = FileFieldConfigurationBuilder.this.fileFilters.isEmpty();
  for (final FileFilter fileFilter : FileFieldConfigurationBuilder.this.fileFilters) {
   flag |= fileFilter.accept(file);
  }
  if (!flag) {
   return IValidationResult.inValid(FileChooserMessages.InvalidFolderName);
  }
  return IValidationResult.valid();
 }
});

代码示例来源:origin: net.anwiba.commons/anwiba-commons-swing-core

@Override
 public IValidationResult validate(final String value) {
  if (StringUtilities.isNullOrEmpty(value)) {
   return IValidationResult.valid();
  }
  if (!isValid(value)) {
   return IValidationResult.inValid(FileChooserMessages.InvalidFolderName);
  }
  final File file = new File(value);
  if (!file.isDirectory()) {
   return IValidationResult.inValid(FileChooserMessages.InvalidFolderName);
  }
  boolean flag = FileFieldConfigurationBuilder.this.fileFilters.isEmpty();
  for (final FileFilter fileFilter : FileFieldConfigurationBuilder.this.fileFilters) {
   flag |= fileFilter.accept(file);
  }
  if (!flag) {
   return IValidationResult.inValid(FileChooserMessages.InvalidFolderName);
  }
  return IValidationResult.valid();
 }
});

相关文章