public class RestrictedFileSystemView extends FileSystemView
Intendend usage:
If the standard JFileChooser cannot open due to an exception, as described in
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6544857
Example:
File currentDir = ...;
JFrame parentFrame = ...;
JFileChooser chooser;
try {
chooser = new JFileChooser(currentDir);
} catch (Exception e) {
chooser = new JFileChooser(currentDir, new RestrictedFileSystemView());
}
int returnValue = chooser.showOpenDialog(parentFrame);
This FileSystemView only provides basic functionality (and probably a poor look & feel), but it can be a life saver if otherwise no dialog pops up in your application.
The implementation does not use sun.awt.shell.* classes.
| Constructor and Description |
|---|
RestrictedFileSystemView()
Creates a new RestrictedFileSystemView object.
|
RestrictedFileSystemView(File defaultDirectory)
Creates a new RestrictedFileSystemView object.
|
| Modifier and Type | Method and Description |
|---|---|
File |
createFileObject(File dir,
String filename)
Returns a File object constructed in dir from the given filename.
|
File |
createFileObject(String path)
Returns a File object constructed from the given path string.
|
protected File |
createFileSystemRoot(File f)
Creates a new
File object for f with correct behavior for a file system root directory. |
File |
createNewFolder(File containingDir) |
File |
getChild(File parent,
String fileName)
DOCUMENT ME!
|
File |
getDefaultDirectory()
Return the user's default starting directory for the file chooser.
|
File[] |
getFiles(File dir,
boolean useFileHiding)
Gets the list of shown (i.e.
|
File |
getHomeDirectory() |
File |
getParentDirectory(File dir)
Returns the parent directory of
dir. |
File[] |
getRoots()
Returns all root partitions on this system.
|
String |
getSystemDisplayName(File f)
Name of a file, directory, or folder as it would be displayed in a system file browser.
|
Icon |
getSystemIcon(File f)
Icon for a file, directory, or folder as it would be displayed in a system file browser.
|
String |
getSystemTypeDescription(File f)
Type description for a file, directory, or folder as it would be displayed in a system file browser.
|
boolean |
isComputerNode(File dir)
Used by UI classes to decide whether to display a special icon for a computer node, e.g.
|
boolean |
isDrive(File dir)
Used by UI classes to decide whether to display a special icon for drives or partitions, e.g.
|
boolean |
isFileSystem(File f)
Checks if
f represents a real directory or file as opposed to a special folder such as
"Desktop". |
boolean |
isFileSystemRoot(File dir)
Is dir the root of a tree in the file system, such as a drive or partition.
|
boolean |
isFloppyDrive(File dir)
Used by UI classes to decide whether to display a special icon for a floppy disk.
|
boolean |
isHiddenFile(File f)
Returns whether a file is hidden or not.
|
boolean |
isParent(File folder,
File file)
DOCUMENT ME!
|
boolean |
isRoot(File f)
Determines if the given file is a root in the navigatable tree(s).
|
Boolean |
isTraversable(File f)
Returns true if the file (directory) can be visited.
|
getFileSystemViewpublic RestrictedFileSystemView()
public RestrictedFileSystemView(File defaultDirectory)
defaultDirectory - DOCUMENT ME!public boolean isRoot(File f)
isRoot in class FileSystemViewf - a File object representing a directorytrue if f is a root in the navigatable tree.isFileSystemRoot(java.io.File)public Boolean isTraversable(File f)
isTraversable in class FileSystemViewf - the Filetrue if the file/directory can be traversed, otherwise falseJFileChooser#isTraversable,
FileView#isTraversablepublic String getSystemDisplayName(File f)
getSystemDisplayName in class FileSystemViewf - a File objectJFileChooser#getNamepublic String getSystemTypeDescription(File f)
getSystemTypeDescription in class FileSystemViewf - a File objectJFileChooser#getTypeDescriptionpublic Icon getSystemIcon(File f)
getSystemIcon in class FileSystemViewf - a File objectJFileChooser#getIconpublic boolean isParent(File folder, File file)
isParent in class FileSystemViewfolder - a File object repesenting a directoryfile - a File objecttrue if folder is a directory and contains file.public File getChild(File parent, String fileName)
getChild in class FileSystemViewparent - a File object repesenting a directoryfileName - a name of a file or folder which exists in parentnew File(parent, fileName).public boolean isFileSystem(File f)
f represents a real directory or file as opposed to a special folder such as
"Desktop". Used by UI classes to decide if a folder is selectable when doing directory choosing.isFileSystem in class FileSystemViewf - a File objecttrue if f is a real file or directory.public boolean isHiddenFile(File f)
isHiddenFile in class FileSystemViewf - DOCUMENT ME!public boolean isFileSystemRoot(File dir)
isFileSystemRoot in class FileSystemViewdir - f a File object representing a directorytrue if f is a root of a filesystemisRoot(java.io.File)public boolean isDrive(File dir)
The default implementation has no way of knowing, so always returns false.
isDrive in class FileSystemViewdir - a directoryfalse alwayspublic boolean isFloppyDrive(File dir)
The default implementation has no way of knowing, so always returns false.
isFloppyDrive in class FileSystemViewdir - a directoryfalse alwayspublic boolean isComputerNode(File dir)
The default implementation has no way of knowing, so always returns false.
isComputerNode in class FileSystemViewdir - a directoryfalse alwayspublic File[] getRoots()
getRoots in class FileSystemViewpublic File getHomeDirectory()
getHomeDirectory in class FileSystemViewpublic File getDefaultDirectory()
getDefaultDirectory in class FileSystemViewFile object representing the default starting folderpublic File createFileObject(File dir, String filename)
createFileObject in class FileSystemViewdir - DOCUMENT ME!filename - DOCUMENT ME!public File createFileObject(String path)
createFileObject in class FileSystemViewpath - DOCUMENT ME!public File[] getFiles(File dir, boolean useFileHiding)
getFiles in class FileSystemViewdir - DOCUMENT ME!useFileHiding - DOCUMENT ME!public File getParentDirectory(File dir)
dir.getParentDirectory in class FileSystemViewdir - the File being querieddir, or null if dir is nullprotected File createFileSystemRoot(File f)
File object for f with correct behavior for a file system root directory.createFileSystemRoot in class FileSystemViewf - a File object representing a file system root directory, for example "/" on Unix or
"C:\" on Windows.File objectpublic File createNewFolder(File containingDir) throws IOException
createNewFolder in class FileSystemViewIOExceptionCopyright © 2012–2026 cismet GmbH. All rights reserved.