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


Java JFileChooser.getSelectedFiles方法代码示例

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


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

示例1: browseLibraryButtonActionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void browseLibraryButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseLibraryButtonActionPerformed
    JFileChooser chooser = new JFileChooser(ModuleUISettings.getDefault().getLastChosenLibraryLocation());
    File[] olds = convertStringToFiles(txtLibrary.getText().trim());
    chooser.setSelectedFiles(olds);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setMultiSelectionEnabled(true);
    chooser.addChoosableFileFilter(new JarZipFilter());
    int ret = chooser.showDialog(this, getMessage("LBL_Select"));
    if (ret == JFileChooser.APPROVE_OPTION) {
        File[] files =  chooser.getSelectedFiles();
        if (files.length == 0) {
            return;
        }
        String path = "";
        for (int i = 0; i < files.length; i++) {
            path = path + files[i] + ( i == files.length - 1 ? "" : File.pathSeparator);
        }
        txtLibrary.setText(path);
        ModuleUISettings.getDefault().setLastChosenLibraryLocation(files[0].getParentFile().getAbsolutePath());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:LibraryStartVisualPanel.java

示例2: showFileSelection

import javax.swing.JFileChooser; //导入方法依赖的package包/类
public static List<Data> showFileSelection() throws Exception{
    List<Data> ret = new ArrayList<Data>();
    
    JFileChooser jfc = new JFileChooser();
    jfc.setMultiSelectionEnabled(true);
    
    jfc.setDialogTitle("Choose the files to sign");
    SignUtils.playBeeps(1);
    if(jfc.showOpenDialog(null) != JFileChooser.APPROVE_OPTION)
        return null;
    
    File[] choosedFileList = jfc.getSelectedFiles();
    for(File file:choosedFileList){
        String id = file.getAbsolutePath();
        byte[] fileContent = IOUtils.readFile(file);
        ret.add(new Data(id, fileContent));
    }
    return ret;
}
 
开发者ID:damianofalcioni,项目名称:Websocket-Smart-Card-Signer,代码行数:20,代码来源:SignUI.java

示例3: addOutputActionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void addOutputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addOutputActionPerformed
    JFileChooser chooser = new JFileChooser();
    FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
    chooser.setFileSelectionMode (JFileChooser.FILES_AND_DIRECTORIES);
    chooser.setMultiSelectionEnabled(true);
    if (lastChosenFile != null) {
        chooser.setSelectedFile(lastChosenFile);
    } else {
        File files[] = model.getBaseFolder().listFiles();
        if (files != null && files.length > 0) {
            chooser.setSelectedFile(files[0]);
        } else {
            chooser.setSelectedFile(model.getBaseFolder());
        }
    }
    chooser.setDialogTitle(NbBundle.getMessage(OutputPanel.class, "LBL_Browse_Output")); // NOI18N
    if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
        for (File file : chooser.getSelectedFiles()) {
            file = FileUtil.normalizeFile(file);
            listModel.addElement(file.getAbsolutePath());
            lastChosenFile = file;
        }
        applyChanges();
        updateButtons();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:OutputPanel.java

示例4: actionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e)
{
	JFileChooser fc = new JFileChooser(lastSelectedDirectory);
	fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
	fc.setMultiSelectionEnabled(true);

	if( fc.showOpenDialog(fileList) == JFileChooser.APPROVE_OPTION )
	{
		File[] selectedFiles = fc.getSelectedFiles();
		if( selectedFiles != null && selectedFiles.length > 0 )
		{
			lastSelectedDirectory = selectedFiles[0];
			if( !lastSelectedDirectory.isDirectory() )
			{
				lastSelectedDirectory = lastSelectedDirectory.getParentFile();
			}

			uploadFiles(fileList.getCurrentDirectory(), selectedFiles);
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:23,代码来源:UploadAction.java

示例5: open

import javax.swing.JFileChooser; //导入方法依赖的package包/类
void open() throws IOException {
	JFileChooser chooser = haxby.map.MapApp.getFileChooser();
	int mode = chooser.getFileSelectionMode();
	boolean multi = chooser.isMultiSelectionEnabled();
	chooser.setMultiSelectionEnabled( true );
	chooser.setFileSelectionMode( JFileChooser.FILES_ONLY );
	chooser.addChoosableFileFilter(imageFileFilter);
	
	int ok = chooser.showOpenDialog(frame);
	File[] choice = null;
	if( ok!=chooser.CANCEL_OPTION ) choice = chooser.getSelectedFiles();
	chooser.setMultiSelectionEnabled(multi);
	chooser.setFileSelectionMode( mode );
	chooser.removeChoosableFileFilter(imageFileFilter);

	if( ok==chooser.CANCEL_OPTION ) {
		return;
	}
	
	if (mapType == MapApp.MERCATOR_MAP)
		openImagesMercator(choice);
	else
		openImagesPolar(choice);
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:25,代码来源:ImportImage.java

示例6: addFileButtonActionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void addFileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addFileButtonActionPerformed
        JFileChooser chooser = new JFileChooser();
        chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        chooser.setMultiSelectionEnabled(true);
        chooser.setDialogTitle(NbBundle.getMessage(SpringCustomizerPanel.class, "LBL_ChooseFile")); //NOI18N
        chooser.setCurrentDirectory(basedir);
        int option = chooser.showOpenDialog(SwingUtilities.getWindowAncestor(groupFilesList));
        if (option == JFileChooser.APPROVE_OPTION) {
            boolean showDialog = false;
            List<File> newFiles = new LinkedList<File>();
            StringBuilder existing = new StringBuilder(
                    NbBundle.getMessage(SpringCustomizerPanel.class, "LBL_FileAlreadyAdded")).append("\n"); //NOI18N
            for (File file : chooser.getSelectedFiles()) {
                if (files.contains(file)) {
                    existing.append(file.getAbsolutePath()).append("\n"); //NOI18N
                    showDialog = true;
                } else {
                    newFiles.add(file);
                }
            }

            // remember last location
            basedir = chooser.getCurrentDirectory();
            addFiles(newFiles);
            if (showDialog) {
                DialogDisplayer.getDefault().notify(
                        new NotifyDescriptor.Message(existing.toString(), NotifyDescriptor.ERROR_MESSAGE));
            }
        }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:SpringCustomizerPanel.java

示例7: showMultiOpenDialog

import javax.swing.JFileChooser; //导入方法依赖的package包/类
/**
 * 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;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:FileChooserBuilder.java

示例8: chooseFilesToOpen

import javax.swing.JFileChooser; //导入方法依赖的package包/类
/**
 * Displays the specified file chooser and returns a list of selected files.
 *
 * @param  chooser  file chooser to display
 * @return  array of selected files,
 * @exception  org.openide.util.UserCancelException
 *                     if the user cancelled the operation
 */
public static File[] chooseFilesToOpen(JFileChooser chooser)
        throws UserCancelException {
    File[] files;
    do {
        int selectedOption = chooser.showOpenDialog(
            WindowManager.getDefault().getMainWindow());
        
        if (selectedOption != JFileChooser.APPROVE_OPTION) {
            throw new UserCancelException();
        }
        files = chooser.getSelectedFiles();
    } while (files.length == 0);
    return files;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:OpenFileAction.java

示例9: recordApproveSelection

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void recordApproveSelection(JFileChooser fc) {
    if (fc.isMultiSelectionEnabled()) {
        File[] fs = fc.getSelectedFiles();
        recorder.recordSelect(this, ChooserHelper.encode(fs));
    } else {
        File file = fc.getSelectedFile();
        recorder.recordSelect(this, ChooserHelper.encode(file));
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:10,代码来源:RFileChooser.java

示例10: chooseMossFileBtnActionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
/**
 * choose the files for moss
 */
private void chooseMossFileBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseMossFileBtnActionPerformed
    // TODO add your handling code here:
    JFileChooser chooseMoss = new JFileChooser();
    chooseMoss.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooseMoss.setMultiSelectionEnabled(true);
    chooseMoss.showOpenDialog(this);
    
    allMossFiles = chooseMoss.getSelectedFiles();
    for(File f : allMossFiles) {
        addedFilesArea.append(f.getAbsolutePath()+"\n");
    }
}
 
开发者ID:bufferhe4d,项目名称:call-IDE,代码行数:16,代码来源:InsMain.java

示例11: selectFile

import javax.swing.JFileChooser; //导入方法依赖的package包/类
/**
 * browse and select the attachment files
 */
private void selectFile() {
    JFileChooser chooser = new JFileChooser(com.cognizant.cognizantits.ide.main.explorer.settings.Settings.getScreenShotLoc());
    chooser.setMultiSelectionEnabled(true);
    chooser.showOpenDialog(this);
    File[] files = chooser.getSelectedFiles();
    for (File f : files) {
        attachments.setText(attachments.getText() + f.getAbsolutePath() + File.pathSeparator);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:13,代码来源:ReportDefect.java

示例12: filterUI

import javax.swing.JFileChooser; //导入方法依赖的package包/类
@Override
public File[] filterUI() {
	JFileChooser chooser = new JFileChooser();
	FileNameExtensionFilter filter = new FileNameExtensionFilter(
			"XML Files", "xml");
	chooser.setFileFilter(filter);
	chooser.setMultiSelectionEnabled(true);
	int returnVal = chooser.showOpenDialog(null);
	if(returnVal == JFileChooser.APPROVE_OPTION) {
		return chooser.getSelectedFiles();
	} else {
		return null;
	}
}
 
开发者ID:SERESLab,项目名称:iTrace-Archive,代码行数:15,代码来源:XMLBasicFixationFilter.java

示例13: filterUI

import javax.swing.JFileChooser; //导入方法依赖的package包/类
@Override
public File[] filterUI() {
	JFileChooser chooser = new JFileChooser();
	FileNameExtensionFilter filter = new FileNameExtensionFilter(
			"JSON Files", "json");
	chooser.setFileFilter(filter);
	chooser.setMultiSelectionEnabled(true);
	int returnVal = chooser.showOpenDialog(null);
	if(returnVal == JFileChooser.APPROVE_OPTION) {
		return chooser.getSelectedFiles();
	} else {
		return null;
	}
}
 
开发者ID:SERESLab,项目名称:iTrace-Archive,代码行数:15,代码来源:JSONBasicFixationFilter.java

示例14: selectFiles

import javax.swing.JFileChooser; //导入方法依赖的package包/类
public static String[] selectFiles(Component component,String name,String extension,File pathToUse){
       JFileChooser chooser = new JFileChooser();
       chooser.setMultiSelectionEnabled(true);
       if(extension != null){
           chooser.setFileFilter(new ExtensionFilter(extension));
       }
       boolean useIndicated = pathToUse != null;
       if (useIndicated && lastIndicatedPath == null){
           lastIndicatedPath = pathToUse;
       }

       chooser.setCurrentDirectory(useIndicated?lastIndicatedPath:lastChooserPath);
int result = chooser.showDialog(component, name);
       if ( result == JFileChooser.APPROVE_OPTION){
           try{
               if(useIndicated){
                   lastIndicatedPath = chooser.getCurrentDirectory();
               }else{
                   lastChooserPath = chooser.getCurrentDirectory();
               }

               File[] files = chooser.getSelectedFiles();
               String[] forReturn = new String[files.length];
               for(int i = 0; i < files.length; i++){
                   forReturn[i] = files[i].getAbsolutePath();
               }
               return forReturn;
           }catch(Exception e){e.printStackTrace();}
       }

       return null;
   }
 
开发者ID:asiermarzo,项目名称:Ultraino,代码行数:33,代码来源:FileUtils.java

示例15: open

import javax.swing.JFileChooser; //导入方法依赖的package包/类
public File[] open(final JPanel panel) {
	JFileChooser fc = new JFileChooser();
	fc.setMultiSelectionEnabled(true);
	fc.setCurrentDirectory(new File(System.getProperty("user.dir")));
	fc.setDialogTitle("Choose File(s)");
	fc.showOpenDialog(panel);
       return fc.getSelectedFiles();
}
 
开发者ID:JudgeGlass,项目名称:Install_Builder_Universal,代码行数:9,代码来源:OpenFile.java


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