- 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 Summary
Constructors Constructor and Description FileSystemView()
-
Method Summary
Methods 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 newFile
object forf
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
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.static FileSystemView
getFileSystemView()
File
getHomeDirectory()
File
getParentDirectory(File dir)
Returns the parent directory ofdir
.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 iff
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)
On Windows, a file can appear in multiple folders, other than its parent directory in the filesystem.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.
-
-
-
Method Detail
-
getFileSystemView
public static FileSystemView getFileSystemView()
-
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 theShellFolder
class.- Parameters:
f
- aFile
object representing a directory- Returns:
true
iff
is a root in the navigatable tree.- See Also:
isFileSystemRoot(java.io.File)
-
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
- theFile
- Returns:
true
if the file/directory can be traversed, otherwisefalse
- Since:
- 1.4
- See Also:
JFileChooser.isTraversable(java.io.File)
,FileView.isTraversable(java.io.File)
-
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
- aFile
object- Returns:
- the file name as it would be displayed by a native file chooser
- Since:
- 1.4
- See Also:
JFileChooser.getName(java.io.File)
-
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
- aFile
object- 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)
-
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
- aFile
object- Returns:
- an icon as it would be displayed by a native file chooser
- Since:
- 1.4
- See Also:
JFileChooser.getIcon(java.io.File)
-
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
- aFile
object repesenting a directory or special folderfile
- aFile
object- Returns:
true
iffolder
is a directory or special folder and containsfile
.- Since:
- 1.4
-
getChild
public File getChild(File parent, String fileName)
- Parameters:
parent
- aFile
object repesenting a directory or special folderfileName
- a name of a file or folder which exists inparent
- 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 theFile
is a wrapper containing aShellFolder
object. - Since:
- 1.4
-
isFileSystem
public boolean isFileSystem(File f)
Checks iff
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
- aFile
object- Returns:
true
iff
is a real file or directory.- Since:
- 1.4
-
createNewFolder
public abstract File createNewFolder(File containingDir) throws IOException
Creates a new folder with a default folder name.- Throws:
IOException
-
isHiddenFile
public boolean isHiddenFile(File f)
Returns whether a file is hidden or not.
-
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
- aFile
object representing a directory- Returns:
true
iff
is a root of a filesystem- Since:
- 1.4
- See Also:
isRoot(java.io.File)
-
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- Since:
- 1.4
-
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- Since:
- 1.4
-
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- Since:
- 1.4
-
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.
-
getHomeDirectory
public File getHomeDirectory()
-
getDefaultDirectory
public File getDefaultDirectory()
Return the user's default starting directory for the file chooser.- Returns:
- a
File
object representing the default starting folder - Since:
- 1.4
-
createFileObject
public File createFileObject(File dir, String filename)
Returns a File object constructed in dir from the given filename.
-
createFileObject
public File createFileObject(String path)
Returns a File object constructed from the given path string.
-
getFiles
public File[] getFiles(File dir, boolean useFileHiding)
Gets the list of shown (i.e. not hidden) files.
-
getParentDirectory
public File getParentDirectory(File dir)
Returns the parent directory ofdir
.- Parameters:
dir
- theFile
being queried- Returns:
- the parent directory of
dir
, ornull
ifdir
isnull
-
createFileSystemRoot
protected File createFileSystemRoot(File f)
Creates a newFile
object forf
with correct behavior for a file system root directory.- Parameters:
f
- aFile
object representing a file system root directory, for example "/" on Unix or "C:\" on Windows.- Returns:
- a new
File
object - Since:
- 1.4
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/swing/filechooser/FileSystemView.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.