This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.swing.filechooser
class FileSystemView

java.lang.Object extended by javax.swing.filechooser.FileSystemView

Most common way to construct:

FileSystemView fsv = FileSystemView.getFileSystemView();

Based on 32 examples


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 Summary

          
 
Method Summary
 File
createFileObject(File dir, String filename)

          Returns a File object constructed in dir from the given filename.
 File

          Returns a File object constructed from the given path string.
protected File

          Creates a new File object for f with correct behavior for a file system root directory.
abstract File
createNewFolder(File containingDir)

          Creates a new folder with a default folder name.
 File
getChild(File parent, String fileName)

          
 File

          Return the user's default starting directory for the file chooser.
 File[]
getFiles(File dir, boolean useFileHiding)

          Gets the list of shown (i.e.
static FileSystemView

          
 File

          
 File

          Returns the parent directory of dir.
 File[]

          Returns all root partitions on this system.
 String

          Name of a file, directory, or folder as it would be displayed in a system file browser.
 Icon

          Icon for a file, directory, or folder as it would be displayed in a system file browser.
 String

          Type description for a file, directory, or folder as it would be displayed in a system file browser.
 boolean

          Used by UI classes to decide whether to display a special icon for a computer node, e.g.
 boolean

          Used by UI classes to decide whether to display a special icon for drives or partitions, e.g.
 boolean

          Checks if f represents a real directory or file as opposed to a special folder such as "Desktop".
 boolean

          Is dir the root of a tree in the file system, such as a drive or partition.
 boolean

          Used by UI classes to decide whether to display a special icon for a floppy disk.
 boolean

          Returns whether a file is hidden or not.
 boolean
isParent(File folder, File file)

          On Windows, a file can appear in multiple folders, other than its parent directory in the filesystem.
 boolean

          Determines if the given file is a root in the navigatable tree(s).
 Boolean

          Returns true if the file (directory) can be visited.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSystemView

public FileSystemView()
Method Detail

createFileObject

public File createFileObject(File dir,
                             String filename)
Returns a File object constructed in dir from the given filename.

Parameters:
dir
filename

createFileObject

public File createFileObject(String path)
Returns a File object constructed from the given path string.

Parameters:
path

createFileSystemRoot

protected File createFileSystemRoot(File f)
Creates a new File object for f with correct behavior for a file system root directory.

Parameters:
f - a File object representing a file system root directory, for example "/" on Unix or "C:\" on Windows.
Returns:
a new File object

createNewFolder

public abstract File createNewFolder(File containingDir)
                              throws IOException
Creates a new folder with a default folder name.

Parameters:
containingDir
Throws:
IOException

getChild

public File getChild(File parent,
                     String fileName)
Parameters:
parent - a File object repesenting 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 the File is a wrapper containing a ShellFolder object.

getDefaultDirectory

public File getDefaultDirectory()
Return the user's default starting directory for the file chooser.

Returns:
a File object representing the default starting folder

getFiles

public File[] getFiles(File dir,
                       boolean useFileHiding)
Gets the list of shown (i.e. not hidden) files.

Parameters:
dir
useFileHiding

getFileSystemView

public static FileSystemView getFileSystemView()

getHomeDirectory

public File getHomeDirectory()

getParentDirectory

public File getParentDirectory(File dir)
Returns the parent directory of dir.

Parameters:
dir - the File being queried
Returns:
the parent directory of dir, or null if dir is null

getRoots

public File[] getRoots()
Returns 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.


getSystemDisplayName

public String getSystemDisplayName(File f)
Name 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 File object
Returns:
the file name as it would be displayed by a native file chooser

getSystemIcon

public Icon getSystemIcon(File f)
Icon 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 File object
Returns:
an icon as it would be displayed by a native file chooser

getSystemTypeDescription

public String getSystemTypeDescription(File f)
Type description for a file, directory, or folder as it would be displayed in a system file browser. Example from Windows: the "Desktop" folder is desribed as "Desktop". Override for platforms with native ShellFolder implementations.

Parameters:
f - a File object
Returns:
the file type description as it would be displayed by a native file chooser or null if no native information is available.

isComputerNode

public boolean isComputerNode(File dir)
Used 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:
false always

isDrive

public boolean isDrive(File dir)
Used 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:
false always

isFileSystem

public boolean isFileSystem(File f)
Checks if 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.

Parameters:
f - a File object
Returns:
true if f is a real file or directory.

isFileSystemRoot

public boolean isFileSystemRoot(File dir)
Is 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 File object representing a directory
Returns:
true if f is a root of a filesystem

isFloppyDrive

public boolean isFloppyDrive(File dir)
Used 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:
false always

isHiddenFile

public boolean isHiddenFile(File f)
Returns whether a file is hidden or not.

Parameters:
f

isParent

public boolean isParent(File folder,
                        File file)
On 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 File object repesenting a directory or special folder
file - a File object
Returns:
true if folder is a directory or special folder and contains file.

isRoot

public boolean isRoot(File f)
Determines if the given file is a root in the navigatable 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 the ShellFolder class.

Parameters:
f - a File object representing a directory
Returns:
true if f is a root in the navigatable tree.

isTraversable

public Boolean isTraversable(File f)
Returns true if the file (directory) can be visited. Returns false if the directory cannot be traversed.

Parameters:
f - the File
Returns:
true if the file/directory can be traversed, otherwise false


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.