java.lang.Object
javax.swing.filechooser.FileSystemView
public abstract class FileSystemView extends Object
FileSystemView is JFileChooser's gateway to the
 file system. Since the JDK1.1 File API doesn't allow
 access to such information as root partitions, file type
 information, or hidden file bits, this class is designed
 to intuit as much OS-specific file system information as
 possible.
 
Java Licensees may want to provide a different implementation of FileSystemView to better handle a given operating system.
- 
Constructor SummaryConstructors Constructor Description FileSystemView()Constructs a FileSystemView.
- 
Method SummaryModifier and Type Method Description FilecreateFileObject(File dir, String filename)Returns a File object constructed in dir from the given filename.FilecreateFileObject(String path)Returns a File object constructed from the given path string.protected FilecreateFileSystemRoot(File f)Creates a newFileobject forfwith correct behavior for a file system root directory.abstract FilecreateNewFolder(File containingDir)Creates a new folder with a default folder name.FilegetChild(File parent, String fileName)File[]getChooserComboBoxFiles()Returns an array of files representing the values which will be shown in the file chooser selector.File[]getChooserShortcutPanelFiles()Returns an array of files representing the values to show by default in the file chooser shortcuts panel.FilegetDefaultDirectory()Return the user's default starting directory for the file chooser.File[]getFiles(File dir, boolean useFileHiding)Gets the list of shown (i.e. not hidden) files.static FileSystemViewgetFileSystemView()Returns the file system view.FilegetHomeDirectory()Returns the home directory.FilegetLinkLocation(File file)Returns the regular file referenced by the specified link file if the specified file is a shell interpreted link.FilegetParentDirectory(File dir)Returns the parent directory ofdir.File[]getRoots()Returns all root partitions on this system.StringgetSystemDisplayName(File f)Name of a file, directory, or folder as it would be displayed in a system file browser.IcongetSystemIcon(File f)Icon for a file, directory, or folder as it would be displayed in a system file browser.StringgetSystemTypeDescription(File f)Type description for a file, directory, or folder as it would be displayed in a system file browser.booleanisComputerNode(File dir)Used by UI classes to decide whether to display a special icon for a computer node, e.g.booleanisDrive(File dir)Used by UI classes to decide whether to display a special icon for drives or partitions, e.g. a "hard disk" icon.booleanisFileSystem(File f)Checks iffrepresents a real directory or file as opposed to a special folder such as"Desktop".booleanisFileSystemRoot(File dir)Is dir the root of a tree in the file system, such as a drive or partition.booleanisFloppyDrive(File dir)Used by UI classes to decide whether to display a special icon for a floppy disk.booleanisHiddenFile(File f)Returns whether a file is hidden or not.booleanisLink(File file)Returns whether the specified file denotes a shell interpreted link which can be obtained by thegetLinkLocation(File).booleanisParent(File folder, File file)On Windows, a file can appear in multiple folders, other than its parent directory in the filesystem.booleanisRoot(File f)Determines if the given file is a root in the navigable tree(s).BooleanisTraversable(File f)Returns true if the file (directory) can be visited.
- 
Constructor Details- 
FileSystemViewpublic FileSystemView()Constructs a FileSystemView.
 
- 
- 
Method Details- 
getFileSystemViewReturns the file system view.- Returns:
- the file system view
 
- 
isRootDetermines if the given file is a root in the navigable tree(s). Examples: Windows 98 has one root, the Desktop folder. DOS has one root per drive letter,C:\,D:\, etc. Unix has one root, the"/"directory. The default implementation gets information from theShellFolderclass.- Parameters:
- f- a- Fileobject representing a directory
- Returns:
- trueif- fis a root in the navigable tree.
- See Also:
- isFileSystemRoot(java.io.File)
 
- 
isTraversableReturns true if the file (directory) can be visited. Returns false if the directory cannot be traversed.- Parameters:
- f- the- File
- Returns:
- trueif the file/directory can be traversed, otherwise- false
- Since:
- 1.4
- See Also:
- JFileChooser.isTraversable(java.io.File),- FileView.isTraversable(java.io.File)
 
- 
getSystemDisplayNameName of a file, directory, or folder as it would be displayed in a system file browser. Example from Windows: the "M:\" directory displays as "CD-ROM (M:)" The default implementation gets information from the ShellFolder class.- Parameters:
- f- a- Fileobject
- Returns:
- the file name as it would be displayed by a native file chooser
- Since:
- 1.4
- See Also:
- JFileChooser.getName(java.io.File)
 
- 
getSystemTypeDescriptionType description for a file, directory, or folder as it would be displayed in a system file browser. Example from Windows: the "Desktop" folder is described as "Desktop". Override for platforms with native ShellFolder implementations.- Parameters:
- f- a- Fileobject
- Returns:
- the file type description as it would be displayed by a native file chooser or null if no native information is available.
- Since:
- 1.4
- See Also:
- JFileChooser.getTypeDescription(java.io.File)
 
- 
getSystemIconIcon for a file, directory, or folder as it would be displayed in a system file browser. Example from Windows: the "M:\" directory displays a CD-ROM icon. The default implementation gets information from the ShellFolder class.- Parameters:
- f- a- Fileobject
- Returns:
- an icon as it would be displayed by a native file chooser
- Since:
- 1.4
- See Also:
- JFileChooser.getIcon(java.io.File)
 
- 
isParentOn Windows, a file can appear in multiple folders, other than its parent directory in the filesystem. Folder could for example be the "Desktop" folder which is not the same as file.getParentFile().- Parameters:
- folder- a- Fileobject representing a directory or special folder
- file- a- Fileobject
- Returns:
- trueif- folderis a directory or special folder and contains- file.
- Since:
- 1.4
 
- 
getChild- Parameters:
- parent- a- Fileobject representing a directory or special folder
- fileName- a name of a file or folder which exists in- parent
- Returns:
- a File object. This is normally constructed with new File(parent, fileName)except when parent and child are both special folders, in which case theFileis a wrapper containing aShellFolderobject.
- Since:
- 1.4
 
- 
isFileSystemChecks iffrepresents 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.- Parameters:
- f- a- Fileobject
- Returns:
- trueif- fis a real file or directory.
- Since:
- 1.4
 
- 
createNewFolderCreates a new folder with a default folder name.- Parameters:
- containingDir- a- Fileobject denoting directory to contain the new folder
- Returns:
- a Fileobject denoting the newly created folder
- Throws:
- IOException- if new folder could not be created
 
- 
isHiddenFileReturns whether a file is hidden or not.- Parameters:
- f- a- Fileobject
- Returns:
- true if the given Filedenotes a hidden file
 
- 
isFileSystemRootIs dir the root of a tree in the file system, such as a drive or partition. Example: Returns true for "C:\" on Windows 98.- Parameters:
- dir- a- Fileobject representing a directory
- Returns:
- trueif- fis a root of a filesystem
- Since:
- 1.4
- See Also:
- isRoot(java.io.File)
 
- 
isDriveUsed by UI classes to decide whether to display a special icon for drives or partitions, e.g. a "hard disk" icon. The default implementation has no way of knowing, so always returns false.- Parameters:
- dir- a directory
- Returns:
- falsealways
- Since:
- 1.4
 
- 
isFloppyDriveUsed by UI classes to decide whether to display a special icon for a floppy disk. Implies isDrive(dir). The default implementation has no way of knowing, so always returns false.- Parameters:
- dir- a directory
- Returns:
- falsealways
- Since:
- 1.4
 
- 
isComputerNodeUsed by UI classes to decide whether to display a special icon for a computer node, e.g. "My Computer" or a network server. The default implementation has no way of knowing, so always returns false.- Parameters:
- dir- a directory
- Returns:
- falsealways
- Since:
- 1.4
 
- 
getRootsReturns all root partitions on this system. For example, on Windows, this would be the "Desktop" folder, while on DOS this would be the A: through Z: drives.- Returns:
- an array of Fileobjects representing all root partitions on this system
 
- 
getHomeDirectoryReturns the home directory.- Returns:
- the home directory
 
- 
getDefaultDirectoryReturn the user's default starting directory for the file chooser.- Returns:
- a Fileobject representing the default starting folder
- Since:
- 1.4
 
- 
createFileObjectReturns a File object constructed in dir from the given filename.- Parameters:
- dir- an abstract pathname denoting a directory
- filename- a- Stringrepresentation of a pathname
- Returns:
- a Fileobject created fromdirandfilename
 
- 
createFileObjectReturns a File object constructed from the given path string.- Parameters:
- path-- Stringrepresentation of path
- Returns:
- a Fileobject created from the givenpath
 
- 
getFilesGets the list of shown (i.e. not hidden) files.- Parameters:
- dir- the root directory of files to be returned
- useFileHiding- determine if hidden files are returned
- Returns:
- an array of Fileobjects representing files and directories in the givendir. It includes hidden files ifuseFileHidingis false.
 
- 
getParentDirectoryReturns the parent directory ofdir.- Parameters:
- dir- the- Filebeing queried
- Returns:
- the parent directory of dir, ornullifdirisnull
 
- 
getChooserComboBoxFilesReturns an array of files representing the values which will be shown in the file chooser selector.- Returns:
- an array of Fileobjects. The array returned may be possibly empty if there are no appropriate permissions.
- Since:
- 9
 
- 
getChooserShortcutPanelFilesReturns an array of files representing the values to show by default in the file chooser shortcuts panel.- Returns:
- an array of Fileobjects. The array returned may be possibly empty if there are no appropriate permissions.
- Since:
- 12
 
- 
isLinkReturns whether the specified file denotes a shell interpreted link which can be obtained by thegetLinkLocation(File).- Parameters:
- file- a file
- Returns:
- whether this is a link
- Throws:
- NullPointerException- if- fileequals- null
- SecurityException- if the caller does not have necessary permissions
- Since:
- 9
- See Also:
- getLinkLocation(File)
 
- 
getLinkLocationReturns the regular file referenced by the specified link file if the specified file is a shell interpreted link. Returnsnullif the specified file is not a shell interpreted link.- Parameters:
- file- a file
- Returns:
- the linked file or null.
- Throws:
- FileNotFoundException- if the linked file does not exist
- NullPointerException- if- fileequals- null
- SecurityException- if the caller does not have necessary permissions
- Since:
- 9
 
- 
createFileSystemRootCreates a newFileobject forfwith correct behavior for a file system root directory.- Parameters:
- f- a- Fileobject representing a file system root directory, for example "/" on Unix or "C:\" on Windows.
- Returns:
- a new Fileobject
- Since:
- 1.4
 
 
-