Java Code Examples for javax.swing.JFileChooser#isFileSelectionEnabled()

The following examples show how to use javax.swing.JFileChooser#isFileSelectionEnabled() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
private String fileNameString(File file) {
	if (file == null) {
		return null;
	} else {
		JFileChooser fc = getFileChooser();
		if (fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) {
			return file.getPath();
		} else {
			return file.getName();
		}
	}
}
 
Example 2
private void doSelectedFileChanged(PropertyChangeEvent e) {
	File f = (File) e.getNewValue();
	JFileChooser fc = getFileChooser();
	if (f != null
			&& (fc.isFileSelectionEnabled() && !f.isDirectory() || f.isDirectory() && fc.isDirectorySelectionEnabled())) {
		setFileName(fileNameString(f));
		setFileSelected();
	}
}
 
Example 3
private void doDirectoryChanged(PropertyChangeEvent e) {
	JFileChooser fc = getFileChooser();
	FileSystemView fsv = fc.getFileSystemView();

	clearIconCache();

	File currentDirectory = fc.getCurrentDirectory();
	this.fileList.updatePath(currentDirectory);

	if (currentDirectory != null) {
		this.directoryComboBoxModel.addItem(currentDirectory);
		getNewFolderAction().setEnabled(currentDirectory.canWrite());
		getChangeToParentDirectoryAction().setEnabled(!fsv.isRoot(currentDirectory));
		getChangeToParentDirectoryAction().setEnabled(!fsv.isRoot(currentDirectory));
		getGoHomeAction().setEnabled(!userHomeDirectory.equals(currentDirectory));

		if (fc.isDirectorySelectionEnabled()) {
			if (fc.isFileSelectionEnabled()) {
				setFileName(null);
			} else {
				if (fsv.isFileSystem(currentDirectory)) {
					setFileName(currentDirectory.getPath());
				} else {
					setFileName(null);
				}
			}
			setFileSelected();
		}
	}
}
 
Example 4
private void doFileSelectionModeChanged(PropertyChangeEvent e) {
	doFilterChanged(e);

	JFileChooser fc = getFileChooser();
	File currentDirectory = fc.getCurrentDirectory();
	if (currentDirectory != null && fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()
			&& fc.getFileSystemView().isFileSystem(currentDirectory)) {
		setFileName(currentDirectory.getPath());
	} else {
		setFileName(null);
	}
	setFileSelected();
}