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

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

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

JFileChooser.setMultiSelectionEnabled介绍

暂无

代码示例

代码示例来源:origin: deathmarine/Luyten

private JFileChooser createFileChooser(String... fileFilters) {
  JFileChooser fc = new JFileChooser();
  for (String fileFilter : fileFilters) {
    fc.addChoosableFileFilter(new FileChooserFileFilter(fileFilter));
  }
  fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
  fc.setMultiSelectionEnabled(false);
  return fc;
}

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

private static JFileChooser createFileChooser() {
 final JFileChooser chooser = new JFileChooser();
 //  sets up default file view
 try {
  chooserFile = new File((new File(".").getCanonicalPath()));
 } catch (Exception e) {
  // go with current directory.
 }
 chooser.setCurrentDirectory(chooserFile);
 chooser.addActionListener(e -> {
  if(e.getActionCommand().equals("ApproveSelection")) {
   chooserFile = chooser.getSelectedFile();
  }
 });
 chooser.setMultiSelectionEnabled(true);
 chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
 return chooser;
}

代码示例来源: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: org.netbeans.api/org-openide-filesystems

/**
 * Show an open dialog with a file chooser set up according to the
 * parameters of this builder.
 * @return A file if the user clicks the accept button and a file or
 * folder was selected at the time the user clicked cancel.
 */
public File showOpenDialog() {
  JFileChooser chooser = createFileChooser();
  if( Boolean.getBoolean("nb.native.filechooser") ) { //NOI18N
    FileDialog fileDialog = createFileDialog( chooser.getCurrentDirectory() );
    if( null != fileDialog ) {
      return showFileDialog(fileDialog, FileDialog.LOAD );
    }
  }
  chooser.setMultiSelectionEnabled(false);
  int dlgResult = chooser.showOpenDialog(findDialogParent());
  if (JFileChooser.APPROVE_OPTION == dlgResult) {
    File result = chooser.getSelectedFile();
    if (result != null && !result.exists()) {
      result = null;
    }
    return result;
  } else {
    return null;
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

chooser.setDialogTitle("Select OGG file");
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
chooser.setMultiSelectionEnabled(false);
if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION){
  btnStopActionPerformed(null);

代码示例来源: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: stackoverflow.com

public void actionPerformed(ActionEvent evt) {
 JFileChooser fileChooser = new JFileChooser();
 fileChooser.setMultiSelectionEnabled(false);
 int result = fileChooser.showOpenDialog(view.getTopWindow());
 if (result == JFileChooser.APPROVE_OPTION) {

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

importFileDialog.setMultiSelectionEnabled(true);

代码示例来源:origin: BaseXdb/basex

/**
 * Allow multiple choice.
 * @return self reference
 */
public BaseXFileChooser multi() {
 if(fc != null) fc.setMultiSelectionEnabled(true);
 return this;
}

代码示例来源:origin: org.basex/basex

/**
 * Allow multiple choice.
 * @return self reference
 */
public BaseXFileChooser multi() {
 if(fc != null) fc.setMultiSelectionEnabled(true);
 return this;
}

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

public void actionPerformed(ActionEvent e) {
    JFileChooser j = new JFileChooser();
    j.setSelectedFile(directory);
    j.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    j.setMultiSelectionEnabled(false);
    if (j.showOpenDialog(StandaloneEditor.this) == JFileChooser.APPROVE_OPTION) {
      File directory = j.getSelectedFile();
      setInputDirectory(directory);
    }
  }
});

代码示例来源: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: otros-systems/otroslogviewer

@Override
 public void actionPerformed(ActionEvent e) {
  chooser.setMultiSelectionEnabled(false);
  chooser.setDialogTitle(Messages.getMessage("authenticator.selectSshKey"));
  int showOpenDialog = chooser.showOpenDialog(null);
  if (showOpenDialog == JFileChooser.APPROVE_OPTION) {
   sshKeyFileField.setText(chooser.getSelectedFile().getAbsolutePath());
  }
 }
});

代码示例来源:origin: nu.zoom.desktop/filechooser

private JFileChooser getChooser() {
  log.trace("Creating a new File chooser");
  JFileChooser chooser = new JFileChooser(getLastDirectory());
  if (filter != null) {
    chooser.setFileFilter(filter);
  }
  chooser.setMultiSelectionEnabled(false);
  chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
  return chooser;
}

代码示例来源:origin: raydac/netbeans-mmd-plugin

private void buttonGraphvizDotFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonGraphvizDotFileActionPerformed
 final JFileChooser fileChooser = new JFileChooser(this.textFieldPathToGraphvizDot.getText());
 fileChooser.setDialogTitle("Select GraphViz dot executable file");
 fileChooser.setApproveButtonText("Select");
 fileChooser.setAcceptAllFileFilterUsed(true);
 fileChooser.setMultiSelectionEnabled(false);
 fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
 if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
  final File file = fileChooser.getSelectedFile();
  this.textFieldPathToGraphvizDot.setText(file.getAbsolutePath());
 }
}//GEN-LAST:event_buttonGraphvizDotFileActionPerformed

代码示例来源:origin: featurecat/lizzie

public static void openFile() {
 FileNameExtensionFilter filter = new FileNameExtensionFilter("*.sgf or *.gib", "SGF", "GIB");
 JSONObject filesystem = Lizzie.config.persisted.getJSONObject("filesystem");
 JFileChooser chooser = new JFileChooser(filesystem.getString("last-folder"));
 chooser.setFileFilter(filter);
 chooser.setMultiSelectionEnabled(false);
 int result = chooser.showOpenDialog(null);
 if (result == JFileChooser.APPROVE_OPTION) loadFile(chooser.getSelectedFile());
}

代码示例来源: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: freeplane/freeplane

private JFileChooser createFileChooser() {
  final JFileChooser fileChooser = new JFileChooser(new File(Compat.getApplicationUserDirectory()));
  fileChooser.setMultiSelectionEnabled(false);
  fileChooser.setAcceptAllFileFilterUsed(false);
  final FileNameExtensionFilter filter = new FileNameExtensionFilter(FILE_EXTENSION, FILE_EXTENSION);
  fileChooser.setFileFilter(filter);
  return fileChooser;
}

相关文章

JFileChooser类方法