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

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

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

JFileChooser.getAcceptAllFileFilter介绍

暂无

代码示例

代码示例来源:origin: chewiebug/GCViewer

public Export(final GCViewerGui gcViewer) {
  this.gcViewer = gcViewer;
  putValue(NAME, LocalisationHelper.getString("main_frame_menuitem_export"));
  putValue(MNEMONIC_KEY, new Integer(LocalisationHelper.getString("main_frame_menuitem_mnemonic_export").charAt(0)));
  putValue(SHORT_DESCRIPTION, LocalisationHelper.getString("main_frame_menuitem_hint_export"));
  putValue(ACTION_COMMAND_KEY, ActionCommands.EXPORT.toString());
  putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('E', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() ));
  putValue(SMALL_ICON, ImageHelper.loadImageIcon("save.png"));
  setEnabled(false);
  saveDialog = new JFileChooser();
  saveDialog.setDialogTitle(LocalisationHelper.getString("fileexport_dialog_title"));
  saveDialog.removeChoosableFileFilter(saveDialog.getAcceptAllFileFilter());
  for (ExportExtensionFileFilter filter : ExportExtensionFileFilter.EXT_FILE_FILTERS) {
    saveDialog.addChoosableFileFilter(filter);
  }
}

代码示例来源:origin: unchartedsoftware/aperture-tiles

@Override
  public void actionPerformed (ActionEvent event) {
    _fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    _fileChooser.setFileFilter(_fileChooser.getAcceptAllFileFilter());
    int returnVal = _fileChooser.showOpenDialog(FileSystemPyramidIOSelector.this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
      File file = _fileChooser.getSelectedFile();
      _rootPathField.setText(file.getAbsolutePath()+"/");
    }
  }
});

代码示例来源:origin: unchartedsoftware/aperture-tiles

@Override
  public void actionPerformed (ActionEvent event) {
    _fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    _fileChooser.setFileFilter(new FileNameExtensionFilter("zip files", "zip"));
    _fileChooser.addChoosableFileFilter(_fileChooser.getAcceptAllFileFilter());
    int returnVal = _fileChooser.showOpenDialog(ZipFilePyramidIOSelector.this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
      File file = _fileChooser.getSelectedFile();
      _zipPathField.setText(file.getAbsolutePath());
    }
  }
});

代码示例来源:origin: de.uni_leipzig.asv.toolbox/toolbox-utils

/**
 * Deletes all extensions from the extension-filter.
 */
public void clearExtensions() {
  eff.clearExtensions();
  chooser.setFileFilter(chooser.getAcceptAllFileFilter());
  // chooser.setFileFilter( eff );
}

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

JFileChooser fileChooser = new JFileChooser();
// select only zip files and add "Zip Files" option
fileChooser.setFileFilter(new FileNameExtensionFilter("Zip Files", "zip"));
// remove "All Files" option
fileChooser.removeChoosableFileFilter(fileChooser.getAcceptAllFileFilter());

代码示例来源:origin: antlr/antlrworks

private void applyExtensions(List extensions, JFileChooser chooser, boolean acceptAll, List<String> descriptions) {
  if(extensions == null || extensions.size() == 0)
    chooser.setAcceptAllFileFilterUsed(acceptAll);
  else {
    chooser.setAcceptAllFileFilterUsed(acceptAll);
    XJFileFilter firstFF = null;
    for(int i=0; i<extensions.size(); i++) {
      XJFileFilter ff = XJFileFilter.createFileFilter(extensions.get(i),
          descriptions.get(i));
      chooser.addChoosableFileFilter(ff);
      if((extensions.size() == 1 || !acceptAll) && i == 0)
        firstFF = ff;
    }
    if(extensions.size() > 1 && acceptAll)
      chooser.setFileFilter(chooser.getAcceptAllFileFilter());
    else
      chooser.setFileFilter(firstFF);
  }
}

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

JFileChooser jfc=new JFileChooser(System.getProperty("user.dir","."));

FileFilter ff = new FileFilter(){
  public boolean accept(File f){
    if(f.isDirectory()) return true;
    else if(f.getName().endsWith(".mp3")) return true;
      else return false;
  }
  public String getDescription(){
    return "MP3 files";
  }
};

jfc.removeChoosableFileFilter(jfc.getAcceptAllFileFilter());
jfc.setFileFilter(ff);

if(jfc.showDialog(frame,"openG")==JFileChooser.APPROVE_OPTION){
    String fileName = jfc.getSelectedFile().getPath();
}

代码示例来源:origin: org.codehaus.izpack/izpack-panel

fileChooser.setMultiSelectionEnabled(false);
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fileChooser.addChoosableFileFilter(fileChooser.getAcceptAllFileFilter());

代码示例来源:origin: org.biojava.thirdparty/forester

MainFrame() {
  _process_pool = ProcessPool.createInstance();
  _writetopdf_filechooser = new JFileChooser();
  _writetopdf_filechooser.setMultiSelectionEnabled( false );
  _writetopdf_filechooser.addChoosableFileFilter( pdffilter );
  _writetographics_filechooser = new JFileChooser();
  _writetographics_filechooser.setMultiSelectionEnabled( false );
  _writetographics_filechooser.addChoosableFileFilter( graphicsfilefilter );
  _save_filechooser = new JFileChooser();
  _save_filechooser.setMultiSelectionEnabled( false );
  _save_filechooser.setFileFilter( xmlfilter );
  _save_filechooser.addChoosableFileFilter( nhfilter );
  _save_filechooser.addChoosableFileFilter( nexusfilter );
  _save_filechooser.addChoosableFileFilter( _save_filechooser.getAcceptAllFileFilter() );
  try {
    final String home_dir = System.getProperty( "user.home" );
    _save_filechooser.setCurrentDirectory( new File( home_dir ) );
    _writetopdf_filechooser.setCurrentDirectory( new File( home_dir ) );
    _writetographics_filechooser.setCurrentDirectory( new File( home_dir ) );
  }
  catch ( final Exception e ) {
    e.printStackTrace();
    // Do nothing. Not important.
  }
}

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

public void removeFileTypes(String... types) {
  for (String type : types) {
    fileTypes.remove(type.toLowerCase());
  }
  if (fileTypes.isEmpty()) {
    fileChooser().resetChoosableFileFilters();
    fileChooser().setFileFilter(fileChooser().getAcceptAllFileFilter());
  }
}

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

private static JFileChooser createFileChooserDialog(final String preferencesKey) {
  final JFileChooser chooser = new SnapFileChooser();
  chooser.setAcceptAllFileFilterUsed(true);
  chooser.setMultiSelectionEnabled(true);
  final String lastDir = SnapApp.getDefault().getPreferences().get(preferencesKey, SystemUtils.getUserHomeDir().getPath());
  chooser.setCurrentDirectory(new File(lastDir));
  final Iterator<ProductReaderPlugIn> iterator = ProductIOPlugInManager.getInstance().getAllReaderPlugIns();
  java.util.List<SnapFileFilter> sortedFileFilters = SnapFileFilter.getSortedFileFilters(iterator);
  sortedFileFilters.forEach(chooser::addChoosableFileFilter);
  chooser.setFileFilter(chooser.getAcceptAllFileFilter());
  return chooser;
}

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

protected JFileChooser createFileChooserDialog() {
  final JFileChooser chooser = new SnapFileChooser();
  chooser.setAcceptAllFileFilterUsed(true);
  chooser.setMultiSelectionEnabled(true);
  final Iterator<ProductReaderPlugIn> iterator = ProductIOPlugInManager.getInstance().getAllReaderPlugIns();
  List<SnapFileFilter> sortedFileFilters = SnapFileFilter.getSortedFileFilters(iterator);
  sortedFileFilters.forEach(chooser::addChoosableFileFilter);
  chooser.setFileFilter(chooser.getAcceptAllFileFilter());
  return chooser;
}

代码示例来源:origin: uk.ac.gate.plugins/annie

@Override
 public void run() {
  JFileChooser fileChooser = MainFrame.getFileChooser();
  fileChooser.setFileFilter(fileChooser.getAcceptAllFileFilter());
  fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
  fileChooser.setMultiSelectionEnabled(false);
  if(fileChooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
   File file = fileChooser.getSelectedFile();
   try (ObjectOutputStream s = new ObjectOutputStream(new FileOutputStream(file));) {
    MainFrame.lockGUI("Serializing JAPE Transducer...");
    serialize(s);
   } catch(IOException ioe) {
    JOptionPane.showMessageDialog(MainFrame.getInstance(), "Error!\n" + ioe.toString(),
        "GATE", JOptionPane.ERROR_MESSAGE);
    ioe.printStackTrace(Err.getPrintWriter());
   } finally {
    MainFrame.unlockGUI();
   }
  }
 }
};

代码示例来源:origin: com.mgmtp.gcviewer/gcviewer

public Export(final GCViewerGui gcViewer) {
  this.gcViewer = gcViewer;
  putValue(NAME, GCViewerGui.localStrings.getString("main_frame_menuitem_export"));
  putValue(MNEMONIC_KEY, new Integer(GCViewerGui.localStrings.getString("main_frame_menuitem_mnemonic_export").charAt(0)));
  putValue(SHORT_DESCRIPTION, GCViewerGui.localStrings.getString("main_frame_menuitem_hint_export"));
  putValue(ACTION_COMMAND_KEY, "export");
  putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('E', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() ));
  putValue(SMALL_ICON, new ImageIcon(Toolkit.getDefaultToolkit().getImage(gcViewer.getClass().getResource("images/save.png"))));
  setEnabled(false);
  
  saveDialog = new JFileChooser();
  saveDialog.setDialogTitle(GCViewerGui.localStrings.getString("fileexport_dialog_title"));
  saveDialog.removeChoosableFileFilter(saveDialog.getAcceptAllFileFilter());
  saveDialog.addChoosableFileFilter(new ExtensionFileFilter(".csv", GCViewerGui.localStrings.getString("fileexport_dialog_csv"), DataWriterType.CSV));
  saveDialog.addChoosableFileFilter(new ExtensionFileFilter(".txt", GCViewerGui.localStrings.getString("fileexport_dialog_txt"), DataWriterType.PLAIN));
  saveDialog.addChoosableFileFilter(new ExtensionFileFilter(".simple.log", GCViewerGui.localStrings.getString("fileexport_dialog_simplelog"), DataWriterType.SIMPLE));
}

代码示例来源:origin: bcdev/beam

private ProductFileChooserAction() {
  super("...");
  chooser = new BeamFileChooser();
  chooser.setDialogTitle("Select Source Product");
  final Iterator<ProductReaderPlugIn> iterator = ProductIOPlugInManager.getInstance().getAllReaderPlugIns();
  List<BeamFileFilter> sortedFileFilters = BeamFileFilter.getSortedFileFilters(iterator);
  for (BeamFileFilter fileFilter : sortedFileFilters) {
    chooser.addChoosableFileFilter(fileFilter);
  }
  chooser.setAcceptAllFileFilterUsed(true);
  chooser.setFileFilter(chooser.getAcceptAllFileFilter());
}

代码示例来源:origin: bcdev/beam

protected JFileChooser createFileChooserDialog() {
  final JFileChooser chooser = new BeamFileChooser();
  chooser.setAcceptAllFileFilterUsed(true);
  chooser.setMultiSelectionEnabled(true);
  final Iterator<ProductReaderPlugIn> iterator = ProductIOPlugInManager.getInstance().getAllReaderPlugIns();
  List<BeamFileFilter> sortedFileFilters = BeamFileFilter.getSortedFileFilters(iterator);
  for (BeamFileFilter productFileFilter : sortedFileFilters) {
    chooser.addChoosableFileFilter(productFileFilter);
  }
  chooser.setFileFilter(chooser.getAcceptAllFileFilter());
  return chooser;
}

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

protected JFileChooser createFileChooserDialog() {
  final JFileChooser chooser = new SnapFileChooser();
  chooser.setAcceptAllFileFilterUsed(true);
  chooser.setMultiSelectionEnabled(true);
  final Iterator<ProductReaderPlugIn> iterator = ProductIOPlugInManager.getInstance().getAllReaderPlugIns();
  List<SnapFileFilter> sortedFileFilters = SnapFileFilter.getSortedFileFilters(iterator);
  sortedFileFilters.forEach(chooser::addChoosableFileFilter);
  chooser.setFileFilter(chooser.getAcceptAllFileFilter());
  return chooser;
}

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

private ProductFileChooserAction() {
  super("...");
  chooser = new SnapFileChooser();
  chooser.setDialogTitle("Select Source Product");
  final Iterator<ProductReaderPlugIn> iterator = ProductIOPlugInManager.getInstance().getAllReaderPlugIns();
  List<SnapFileFilter> sortedFileFilters = SnapFileFilter.getSortedFileFilters(iterator);
  for (SnapFileFilter fileFilter : sortedFileFilters) {
    chooser.addChoosableFileFilter(fileFilter);
  }
  chooser.setAcceptAllFileFilterUsed(true);
  chooser.setFileFilter(chooser.getAcceptAllFileFilter());
}

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

/**
 * Recover the dialog state on the last save state, using the dialog identifier.
 * The following properties may be overwritten
 *  - Current directory
 *  - Current filter
 */
@Override
public void loadState() {
    // Load persistence data
    String currentFolder = UIFactory.getFileDialogPersistence().getProperty(id+":folder");
    if(currentFolder!=null) {
        setCurrentDirectory(new File(currentFolder));
    }
    String currentFilter = UIFactory.getFileDialogPersistence().getProperty(id+":filter");
    if(currentFilter!=null && !setCurrentFilter(Integer.valueOf(currentFilter))) {
        // If the filter is not found, do not use filter, if allowed
        if(getFileChooser().isAcceptAllFileFilterUsed()) {
            getFileChooser().setFileFilter(getFileChooser().getAcceptAllFileFilter());
        }
    }
}
/**

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

public URI getLinkByFileChooser(final MapModel map) {
  JFileChooser chooser = null;
  final File file = map.getFile();
  if (file == null && LinkController.getLinkType() == LinkController.LINK_RELATIVE_TO_MINDMAP) {
    JOptionPane.showMessageDialog(
      Controller.getCurrentController().getViewController().getCurrentRootComponent(),
      TextUtils.getText("not_saved_for_link_error"), "Freeplane", JOptionPane.WARNING_MESSAGE);
    return null;
  }
  if (getLastCurrentDir() != null) {
    chooser = new JFileChooser(getLastCurrentDir());
  }
  else {
    chooser = new JFileChooser();
  }
  chooser.setAcceptAllFileFilterUsed(true);
  chooser.setFileFilter(chooser.getAcceptAllFileFilter());
  chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
  final int returnVal = chooser.showOpenDialog(Controller.getCurrentController().getViewController()
    .getCurrentRootComponent());
  if (returnVal != JFileChooser.APPROVE_OPTION) {
    return null;
  }
  final File input = chooser.getSelectedFile();
  setLastCurrentDir(input.getParentFile());
  return LinkController.toLinkTypeDependantURI(file, input);
}

相关文章

JFileChooser类方法