当前位置: 首页>>代码示例>>Java>>正文


Java JFileChooser.getChoosableFileFilters方法代码示例

本文整理汇总了Java中javax.swing.JFileChooser.getChoosableFileFilters方法的典型用法代码示例。如果您正苦于以下问题:Java JFileChooser.getChoosableFileFilters方法的具体用法?Java JFileChooser.getChoosableFileFilters怎么用?Java JFileChooser.getChoosableFileFilters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JFileChooser的用法示例。


在下文中一共展示了JFileChooser.getChoosableFileFilters方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onExportFilenameBrowseClick

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void onExportFilenameBrowseClick() {
    File oldFile = getExecutableFile();
    JFileChooser fileChooser = new AccessibleJFileChooser(NbBundle.getMessage(MercurialOptionsPanelController.class, "ACSD_ExportBrowseFolder"), oldFile);   // NOI18N
    fileChooser.setDialogTitle(NbBundle.getMessage(MercurialOptionsPanelController.class, "ExportBrowse_title"));                                            // NOI18N
    fileChooser.setMultiSelectionEnabled(false);
    FileFilter[] old = fileChooser.getChoosableFileFilters();
    for (int i = 0; i < old.length; i++) {
        FileFilter fileFilter = old[i];
        fileChooser.removeChoosableFileFilter(fileFilter);
    }
    fileChooser.showDialog(panel, NbBundle.getMessage(MercurialOptionsPanelController.class, "OK_Button"));                                            // NOI18N
    File f = fileChooser.getSelectedFile();
    if (f != null) {
        panel.exportFilenameTextField.setText(f.getAbsolutePath());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:MercurialOptionsPanelController.java

示例2: prepareFileChooser

import javax.swing.JFileChooser; //导入方法依赖的package包/类
/**
 * Creates and initializes a file chooser.
 *
 * @return  the initialized file chooser
 */
protected JFileChooser prepareFileChooser() {
    FileChooserBuilder fcb = new FileChooserBuilder(OpenFileAction.class);
    fcb.setSelectionApprover(new OpenFileSelectionApprover());
    fcb.setFilesOnly(true);
    fcb.addDefaultFileFilters();
    for (OpenFileDialogFilter filter :
            Lookup.getDefault().lookupAll(OpenFileDialogFilter.class)) {
        fcb.addFileFilter(filter);
    }
    JFileChooser chooser = fcb.createFileChooser();
    chooser.setMultiSelectionEnabled(true);
    chooser.getCurrentDirectory().listFiles(); //preload
    chooser.setCurrentDirectory(getCurrentDirectory());
    if (currentFileFilter != null) {
        for (FileFilter ff : chooser.getChoosableFileFilters()) {
            if (currentFileFilter.equals(ff.getDescription())) {
                chooser.setFileFilter(ff);
                break;
            }
        }
    }
    HelpCtx.setHelpIDString(chooser, getHelpCtx().getHelpID());
    return chooser;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:OpenFileAction.java

示例3: apply

import javax.swing.JFileChooser; //导入方法依赖的package包/类
/**
 * Applies the file filter list
 * 
 * @param chooser 
 */
public void apply(JFileChooser chooser) {
    for (FileFilter choosableFileFilter : chooser.getChoosableFileFilters()) {
        chooser.removeChoosableFileFilter(choosableFileFilter);
    }
    for (FileFilter fileFilter : this) {
        chooser.addChoosableFileFilter(fileFilter);
    }
}
 
开发者ID:VISNode,项目名称:VISNode,代码行数:14,代码来源:FileFilterFactory.java

示例4: loadFromFile

import javax.swing.JFileChooser; //导入方法依赖的package包/类
public void loadFromFile() {
    final JFileChooser chooser = new AccessibleJFileChooser(NbBundle.getMessage(SvnProperties.class, "ACSD_Properties"));
    chooser.setDialogTitle(NbBundle.getMessage(SvnProperties.class, "CTL_Load_Value_Title"));
    chooser.setMultiSelectionEnabled(false);
    javax.swing.filechooser.FileFilter[] fileFilters = chooser.getChoosableFileFilters();
    for (int i = 0; i < fileFilters.length; i++) {
        javax.swing.filechooser.FileFilter fileFilter = fileFilters[i];
        chooser.removeChoosableFileFilter(fileFilter);
    }

    chooser.setCurrentDirectory(roots[0].getParentFile()); // NOI18N
    chooser.addChoosableFileFilter(new javax.swing.filechooser.FileFilter() {
        @Override
        public boolean accept(File f) {
            return f.exists();
        }
        @Override
        public String getDescription() {
            return "";
        }
    });

    chooser.setDialogType(JFileChooser.OPEN_DIALOG);
    chooser.setApproveButtonMnemonic(NbBundle.getMessage(SvnProperties.class, "MNE_LoadValue").charAt(0));
    chooser.setApproveButtonText(NbBundle.getMessage(SvnProperties.class, "CTL_LoadValue"));
    DialogDescriptor dd = new DialogDescriptor(chooser, NbBundle.getMessage(SvnProperties.class, "CTL_Load_Value_Title"));
    dd.setOptions(new Object[0]);
    final Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);

    chooser.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String state = e.getActionCommand();
            if (state.equals(JFileChooser.APPROVE_SELECTION)) {
                File source = chooser.getSelectedFile();

                if (Utils.isFileContentText(source)) {
                    if (source.canRead()) {
                        StringWriter sw = new StringWriter();
                        try {
                            Utils.copyStreamsCloseAll(sw, new FileReader(source));
                            panel.txtAreaValue.setText(sw.toString());
                        } catch (IOException ex) {
                            Subversion.LOG.log(Level.SEVERE, null, ex);
                        }
                    }
                } else {
                    handleBinaryFile(source);
                }
            }
            dialog.dispose();
        }
    });
    dialog.setVisible(true);

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:57,代码来源:SvnProperties.java

示例5: createFileChooser

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private JFileChooser createFileChooser(File curentDir) {
    final JFileChooser chooser = new AccessibleJFileChooser(NbBundle.getMessage(ExportDiffSupport.class, "ACSD_Export"));
    chooser.setDialogTitle(NbBundle.getMessage(ExportDiffSupport.class, "CTL_Export_Title"));
    chooser.setMultiSelectionEnabled(false);
    javax.swing.filechooser.FileFilter[] old = chooser.getChoosableFileFilters();
    for (int i = 0; i < old.length; i++) {
        javax.swing.filechooser.FileFilter fileFilter = old[i];
        chooser.removeChoosableFileFilter(fileFilter);

    }
    chooser.setCurrentDirectory(curentDir); // NOI18N
    chooser.addChoosableFileFilter(getFileFilter());

    chooser.setDialogType(JFileChooser.SAVE_DIALOG);
    chooser.setApproveButtonMnemonic(NbBundle.getMessage(ExportDiffSupport.class, "MNE_Export_ExportAction").charAt(0));
    chooser.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String state = e.getActionCommand();
            if (state.equals(JFileChooser.APPROVE_SELECTION)) {
                File destination = chooser.getSelectedFile();
                destination = getTargetFile(destination);
                if (destination.exists()) {
                    NotifyDescriptor nd = new NotifyDescriptor.Confirmation(NbBundle.getMessage(ExportDiffSupport.class, "BK3005", destination.getAbsolutePath()));
                    nd.setOptionType(NotifyDescriptor.YES_NO_OPTION);
                    DialogDisplayer.getDefault().notify(nd);
                    if (nd.getValue().equals(NotifyDescriptor.OK_OPTION) == false) {
                        return;
                    }
                }
                preferences.put("ExportDiff.saveFolder", destination.getParent()); // NOI18N
                panel.setOutputFileText(destination.getAbsolutePath());
            } else {
                dd.setValue(null);
            }
            if(dialog != null) {
                dialog.dispose();
            }
        }
    });
    return chooser;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:42,代码来源:ExportDiffSupport.java


注:本文中的javax.swing.JFileChooser.getChoosableFileFilters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。