Java Code Examples for javax.swing.JFileChooser.isMultiSelectionEnabled()

The following are Jave code examples for showing how to use isMultiSelectionEnabled() of the javax.swing.JFileChooser class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: geomapapp   File: ImportImage.java   Source Code and License Vote up 6 votes
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);
}
 
Example 2
Project: rapidminer   File: FileChooserUI.java   Source Code and License Vote up 5 votes
@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();
}
 
Example 3
Project: marathonv5   File: JFileChooserJavaElement.java   Source Code and License Vote up 5 votes
@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;
}
 
Example 4
Project: marathonv5   File: RFileChooser.java   Source Code and License Vote up 5 votes
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));
    }
}
 
Example 5
Project: incubator-netbeans   File: J2SEVolumeCustomizer.java   Source Code and License Vote up 4 votes
private void addResource(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addResource
    // TODO add your handling code here:
    JFileChooser chooser = new JFileChooser();
    FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
    chooser.setAcceptAllFileFilterUsed(false);
    if (this.volumeType.equals(PersistenceLibrarySupport.VOLUME_TYPE_CLASSPATH)) {
        chooser.setMultiSelectionEnabled (true);
        chooser.setDialogTitle(NbBundle.getMessage(J2SEVolumeCustomizer.class,"TXT_OpenClasses"));
        chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
        chooser.setFileFilter (new SimpleFileFilter(NbBundle.getMessage(
                J2SEVolumeCustomizer.class,"TXT_Classpath"),new String[] {"ZIP","JAR"}));   //NOI18N
        chooser.setApproveButtonText(NbBundle.getMessage(J2SEVolumeCustomizer.class,"CTL_SelectCP"));
        chooser.setApproveButtonMnemonic(NbBundle.getMessage(J2SEVolumeCustomizer.class,"MNE_SelectCP").charAt(0));
    }
    else if (this.volumeType.equals(PersistenceLibrarySupport.VOLUME_TYPE_JAVADOC)) {
        chooser.setDialogTitle(NbBundle.getMessage(J2SEVolumeCustomizer.class,"TXT_OpenJavadoc"));
        chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
        chooser.setFileFilter (new SimpleFileFilter(NbBundle.getMessage(
                J2SEVolumeCustomizer.class,"TXT_Javadoc"),new String[] {"ZIP","JAR"}));     //NOI18N
        chooser.setApproveButtonText(NbBundle.getMessage(J2SEVolumeCustomizer.class,"CTL_SelectJD"));
        chooser.setApproveButtonMnemonic(NbBundle.getMessage(J2SEVolumeCustomizer.class,"MNE_SelectJD").charAt(0));
    }
    else if (this.volumeType.equals(PersistenceLibrarySupport.VOLUME_TYPE_SRC)) {
        chooser.setDialogTitle(NbBundle.getMessage(J2SEVolumeCustomizer.class,"TXT_OpenSources"));
        chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
        chooser.setFileFilter (new SimpleFileFilter(NbBundle.getMessage(
                J2SEVolumeCustomizer.class,"TXT_Sources"),new String[] {"ZIP","JAR"}));     //NOI18N
        chooser.setApproveButtonText(NbBundle.getMessage(J2SEVolumeCustomizer.class,"CTL_SelectSRC"));
        chooser.setApproveButtonMnemonic(NbBundle.getMessage(J2SEVolumeCustomizer.class,"MNE_SelectSRC").charAt(0));
    }
    if (lastFolder != null) {
        chooser.setCurrentDirectory (lastFolder);
    }
    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
        try {
            lastFolder = chooser.getCurrentDirectory();
            if (chooser.isMultiSelectionEnabled()) {
                addFiles (chooser.getSelectedFiles());
            }
            else {
                final File selectedFile = chooser.getSelectedFile();                    
                addFiles (new File[] {selectedFile});
            }
        } catch (MalformedURLException mue) {
            Exceptions.printStackTrace(mue);
        }
    }
}