本文整理汇总了Java中javax.swing.JFileChooser.getFileSystemView方法的典型用法代码示例。如果您正苦于以下问题:Java JFileChooser.getFileSystemView方法的具体用法?Java JFileChooser.getFileSystemView怎么用?Java JFileChooser.getFileSystemView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JFileChooser
的用法示例。
在下文中一共展示了JFileChooser.getFileSystemView方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doDirectoryChanged
import javax.swing.JFileChooser; //导入方法依赖的package包/类
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() && !fc.isFileSelectionEnabled()) {
if (fsv.isFileSystem(currentDirectory)) {
setFileName(currentDirectory.getPath());
} else {
setFileName(null);
}
setFileSelected();
}
}
}
示例2: 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();
}