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

The following are Jave code examples for showing how to use getFileSelectionMode() 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: incubator-netbeans   File: DelegatingChooserUI.java   Source Code and License Vote up 5 votes
/** Returns dirchooser for DIRECTORIES_ONLY, default filechooser for other
 * selection modes.
 */
private static Class<?> getCurChooser (JFileChooser fc) {
    if (fc.getFileSelectionMode() == JFileChooser.DIRECTORIES_ONLY) {
        return DirectoryChooserUI.class;
    }
    return Module.getOrigChooser();
}