當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。