javax.swing.JFileChooser.getSelectedFiles()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(197)

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

JFileChooser.getSelectedFiles介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

JFileChooser chooser = new JFileChooser();
chooser.setMultiSelectionEnabled(true);
chooser.showOpenDialog(frame);
File[] files = chooser.getSelectedFiles();
if(files.length >= 2) {
  compare(readFileAsList(files[0]), readFileAsList(files[1]));
}

代码示例来源:origin: stackoverflow.com

JFileChooser chooser = new JFileChooser();
chooser.setMultiSelectionEnabled(true);
chooser.showOpenDialog(frame);
File[] files = chooser.getSelectedFiles();

代码示例来源:origin: org.netbeans.api/org-openide-filesystems

/**
 * Show an open dialog that allows multiple selection.
 * @return An array of files, or null if the user cancelled the dialog
 */
public File[] showMultiOpenDialog() {
  JFileChooser chooser = createFileChooser();
  chooser.setMultiSelectionEnabled(true);
  int result = chooser.showOpenDialog(findDialogParent());
  if (JFileChooser.APPROVE_OPTION == result) {
    File[] files = chooser.getSelectedFiles();
    return files == null ? new File[0] : files;
  } else {
    return null;
  }
}

代码示例来源:origin: stanfordnlp/CoreNLP

private void doLoadFiles() {
 if (chooser == null) {
  chooser = createFileChooser();
 }
 String approveText = chooser.getApproveButtonText();
 chooser.setApproveButtonText("Load with file filters");
 int status = chooser.showOpenDialog(this);
 chooser.setApproveButtonText(approveText);
 if (status == JFileChooser.APPROVE_OPTION) {
  //now set up the file filters if there are directories
  File[] selectedFiles = chooser.getSelectedFiles();
  boolean haveDirectory = false;
  for (File f : selectedFiles) {
   if (f.isDirectory()) {
    haveDirectory = true;
    break;
   }
  }
  if (haveDirectory) {
   doFileFilters(selectedFiles);
  } else {
   startFileLoadingThread(new EnumMap<>(FilterType.class), selectedFiles);
  }
 }
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * Do the stuff for this class (create the file)
 * 
 * @throws Exception
 */
public static void main(String args[]) throws Exception {
  System.out.println("Starting...");
  
  String wd = "./test";
  
  // choose the directory to open
  JFileChooser chooser = new JFileChooser();
  chooser.setCurrentDirectory(new File(wd));
  chooser.setMultiSelectionEnabled(true);
  chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  int result = chooser.showOpenDialog(null);
  
  if (result == JFileChooser.APPROVE_OPTION) {
    File[] dirs = chooser.getSelectedFiles();
    
    for (File directory : dirs) {
      System.out.println("Doing migration on directory: " + directory.getAbsolutePath());
      doMigration(directory);
    }
  }
}

代码示例来源:origin: ron190/jsql-injection

Arrays.asList(importFileDialog.getSelectedFiles()),
  this.dndList.locationToIndex(mouseEvent.getPoint())
);

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

@Override
  public File[] getSelectedFiles() {

    return super.getSelectedFiles();

//        if (!nativeDialogsShallBeUsed()) {
//            return super.getSelectedFiles();
//        }
//        if (currentFiles == null) {
//            return null;
//        }
//        return currentFiles.toArray(new File[currentFiles.size()]);
  }

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

@Override
public File[] getSelectedFiles() {
 if (!JAVAFX_AVAILABLE) {
  return super.getSelectedFiles();
 }
 if (currentFiles == null) {
  return null;
 }
 return currentFiles.toArray(new File[currentFiles.size()]);
}

代码示例来源:origin: stackoverflow.com

JFileChooser chooser = new JFileChooser();
chooser.setMultiSelectionEnabled(true);

// Show the dialog; wait until dialog is closed
chooser.showOpenDialog(frame);

// Retrieve the selected files.
File[] files = chooser.getSelectedFiles();

代码示例来源:origin: stackoverflow.com

JFileChooser chooser = new JFileChooser();
chooser.setMultiSelectionEnabled(true);

Component frame = null;

chooser.showOpenDialog(frame);
File[] files = chooser.getSelectedFiles();

代码示例来源:origin: stackoverflow.com

JFileChooser jfc = new JFileChooser();
File[] files = jfc.getSelectedFiles();
jfc.setMultiSelectionEnabled(true);
jfc.showOpenDialog(null);

if ( files != null && files.length > 0) {
  for ( File file : files ) {
    layoutmanager.add(new JButton("Filename")); // Or anything else you want to do with the files/buttons
  }
}

代码示例来源:origin: org.databene/databene-commons

void add() {
  int action = chooser.showOpenDialog(this);
  if (action == JFileChooser.APPROVE_OPTION ) {
    File[] selectedFiles = chooser.getSelectedFiles();
    for (File file : selectedFiles)
      model.add(file);
  }
}

代码示例来源:origin: cytoscape/application

private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {
  // Add a directory
  final JFileChooser chooser = new JFileChooser();
  chooser.setDialogTitle("Select Image Directory");
  chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  chooser.setMultiSelectionEnabled(true);
  int returnVal = chooser.showOpenDialog(this);
  if (returnVal == JFileChooser.APPROVE_OPTION)
    importFromDirectories(chooser.getSelectedFiles());
}

代码示例来源:origin: org.cytoscape/ding-customgraphics-manager-impl

private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {
  // Add a directory
  final JFileChooser chooser = new JFileChooser();
  chooser.setDialogTitle("Select Image Directory");
  chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  chooser.setMultiSelectionEnabled(true);
  int returnVal = chooser.showOpenDialog(this);
  if (returnVal == JFileChooser.APPROVE_OPTION)
    importFromDirectories(chooser.getSelectedFiles());
}

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

public File[] getSelectedFiles() {
  if (fileChooser.isMultiSelectionEnabled()) {
    return fileChooser.getSelectedFiles();
  } else {
    return new File[] { fileChooser.getSelectedFile() };
  }
}

代码示例来源:origin: stackoverflow.com

`JFileChooser dialog = new JFileChooser();
dialog.setMultiSelectionEnabled(true);
dialog.showOpenDialog(null);
dialog.addChoosableFileFilter(new FileNameExtensionFilter("pngFilter", "png"));
dialog.addChoosableFileFilter(new FileNameExtensionFilter("jpgFilter", "jpg"));
File[] file = dialog.getSelectedFiles();`

代码示例来源:origin: de.schlichtherle.truezip/truezip-file

@Override
  public @Nullable TFile[] getSelectedFiles() {
    final File files[] = super.getSelectedFiles();
    if (null == files)
      return null; // no directory
    final TFileSystemView fsv = getFileSystemView();
    final TFile[] results = new TFile[files.length];
    for (int i = files.length; 0 <= --i; )
      results[i] = fsv.wrap(files[i]);
    return results;
  }
}

代码示例来源:origin: UNIVALI-LITE/Portugol-Studio

@Override
  public void actionPerformed(ActionEvent e) {
    JFileChooser dialogoSelecaoArquivo = criarSeletorArquivo();
    if (dialogoSelecaoArquivo.showOpenDialog(telaPrincipal) == JFileChooser.APPROVE_OPTION) {
      final File[] arquivos = dialogoSelecaoArquivo.getSelectedFiles();
      final List<File> listaArquivos = new ArrayList<>(Arrays.asList(arquivos));
      telaPrincipal.abrirArquivosCodigoFonte(listaArquivos);
    }
    Configuracoes.getInstancia().setCaminhoUltimoDiretorio(dialogoSelecaoArquivo.getCurrentDirectory());
  }
};

代码示例来源:origin: senbox-org/snap-desktop

private static File[] getSelectedFiles() {
  final JFileChooser fileChooser = createFileChooserDialog(lastLandcoverPathKey);
  int result = fileChooser.showOpenDialog(SnapApp.getDefault().getMainFrame());
  if (fileChooser.getCurrentDirectory() != null) {
    SnapApp.getDefault().getPreferences().put(lastLandcoverPathKey, fileChooser.getCurrentDirectory().getPath());
  }
  if (result == JFileChooser.APPROVE_OPTION) {
    return fileChooser.getSelectedFiles();
  }
  return null;
}

代码示例来源:origin: UNIVALI-LITE/Portugol-Studio

@Override
  public void actionPerformed(ActionEvent e) {
    JFileChooser dialogoSelecaoArquivo = criarSeletorPlugin();
    if (dialogoSelecaoArquivo.showOpenDialog(PortugolStudio.getInstancia().getTelaPrincipal()) == JFileChooser.APPROVE_OPTION) {
      final File[] arquivos = dialogoSelecaoArquivo.getSelectedFiles();
      final List<File> listaArquivos = new ArrayList<>(Arrays.asList(arquivos));
      dialogoPai.setVisible(false);
      GerenciadorPlugins.getInstance().instalarPlugins(listaArquivos);
    }
    Configuracoes.getInstancia().setCaminhoUltimoDiretorio(dialogoSelecaoArquivo.getCurrentDirectory());
  }
});

相关文章

JFileChooser类方法