public void actionPerformed(ActionEvent e) {
if (readOnly) {
return;
}
JFileChooser fc = getFileChooser();
File currentDirectory = fc.getCurrentDirectory();
if (!currentDirectory.exists()) {
JOptionPane.showMessageDialog(
fc,
newFolderParentDoesntExistText,
newFolderParentDoesntExistTitleText, JOptionPane.WARNING_MESSAGE);
return;
}
File newFolder;
try {
newFolder = fc.getFileSystemView().createNewFolder(currentDirectory);
if (fc.isMultiSelectionEnabled()) {
fc.setSelectedFiles(new File[] { newFolder });
} else {
fc.setSelectedFile(newFolder);
}
} catch (IOException exc) {
JOptionPane.showMessageDialog(
fc,
newFolderErrorText + newFolderErrorSeparator + exc,
newFolderErrorText, JOptionPane.ERROR_MESSAGE);
return;
}
fc.rescanCurrentDirectory();
}
|