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


Java JFileChooser.setSelectedFiles方法代码示例

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


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

import javax.swing.JFileChooser; //导入方法依赖的package包/类
public @Override void actionPerformed(ActionEvent evt) {
    JFileChooser chooser = ProjectChooserAccessory.createProjectChooser( true ); // Create the jFileChooser
    chooser.setMultiSelectionEnabled( true );
    
    // Check to see if the current selection matches a file/folder owned by a non-open project;
    // if so, use that as the starting directory, as a convenience in case that is what should be opened.
    // XXX may also want to check lookup for FileObject
    for (DataObject d : Utilities.actionsGlobalContext().lookupAll(DataObject.class)) {
        Project selected = FileOwnerQuery.getOwner(d.getPrimaryFile());
        if (selected != null && !OpenProjectList.getDefault().isOpen(selected)) {
            File dir = FileUtil.toFile(selected.getProjectDirectory());
            if (dir != null) {
                chooser.setCurrentDirectory(dir.getParentFile());
                chooser.setSelectedFiles(new File[] {dir});
                break;
            }
        }
    }
    show(chooser);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:OpenProject.java

示例3: actionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
	if (UIManager.getBoolean("FileChooser.readOnly")) {
		return;
	}
	JFileChooser fc = getFileChooser();
	File currentDirectory = fc.getCurrentDirectory();
	FileSystemView fsv = fc.getFileSystemView();
	File newFolder = null;

	String name = SwingTools.showInputDialog("file_chooser.new_folder", "");

	try {
		if (name != null && !"".equals(name)) {
			newFolder = fsv.createNewFolder(currentDirectory);
			if (newFolder.renameTo(fsv.createFileObject(fsv.getParentDirectory(newFolder), name))) {
				newFolder = fsv.createFileObject(fsv.getParentDirectory(newFolder), name);
			} else {
				SwingTools.showVerySimpleErrorMessage("file_chooser.new_folder.rename", name);
			}
		}
	} catch (IOException exc) {
		SwingTools.showVerySimpleErrorMessage("file_chooser.new_folder.create", name);
		return;
	} catch (Exception exp) {
		// do nothing
	}

	if (fc.isMultiSelectionEnabled()) {
		fc.setSelectedFiles(new File[] { newFolder });
	} else {
		fc.setSelectedFile(newFolder);
	}

	fc.rescanCurrentDirectory();
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:37,代码来源:FileChooserUI.java

示例4: marathon_select

import javax.swing.JFileChooser; //导入方法依赖的package包/类
@Override public boolean marathon_select(String value) {
    JFileChooser fc = (JFileChooser) component;
    if (value.equals("")) {
        fc.cancelSelection();
        return true;
    }
    if (fc.isMultiSelectionEnabled()) {
        fc.setSelectedFiles(ChooserHelper.decode(value));
        fc.approveSelection();
        return true;
    }
    fc.setSelectedFile(ChooserHelper.decodeFile(value));
    fc.approveSelection();
    return true;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:16,代码来源:JFileChooserJavaElement.java

示例5: save

import javax.swing.JFileChooser; //导入方法依赖的package包/类
/**
 * Shows a file chooser and exports the plot to the selected image file.
 * @throws IOException if an error occurs during writing.
 */
public void save() throws IOException {
    JFileChooser fc = FileChooser.getInstance();
    fc.setFileFilter(FileChooser.SimpleFileFilter.getWritableImageFIlter());
    fc.setAcceptAllFileFilterUsed(false);
    fc.setSelectedFiles(new File[0]);
    int returnVal = fc.showSaveDialog(this);

    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
        save(file);
    }        
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:17,代码来源:PlotPanel.java


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