API java : FileSystemView


javax.swing.filechooser
Class FileSystemView

java.lang.Object
  extended by 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
FileSystemView()
           
 
Method Summary
 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.
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 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)
          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.
 
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

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 the ShellFolder class.

Parameters:
f - a File object representing a directory
Returns:
true if f 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 - the File
Returns:
true if the file/directory can be traversed, otherwise false
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 - a File object
Returns:
the file name as it would be displayed by a native file chooser
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 - 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.
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 - a File object
Returns:
an icon as it would be displayed by a native file chooser
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 - 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.

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.

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.

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:
f - a File object representing a directory
Returns:
true if f is a root of a filesystem
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

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

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

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

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 of dir.

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

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

Ces informations proviennent du site de http://java.sun.com

Remarques

Contenu

Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :

Quels sont les motivations de cette démarche?

Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.

Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.

Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.

Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.

Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.

Réseaux sociaux

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.

 

Nuage de mots clés

7 mots clés dont 0 définis manuellement (plus d'information...).

Avertissement

Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.

 

Astuce pour imprimer les couleurs des cellules de tableaux : http://www.gaudry.be/ast-rf-450.html
Aucun commentaire pour cette page

© Ce document issu de l′infobrol est enregistré sous le certificat Cyber PrInterDeposit Digital Numbertection. Enregistrement IDDN n° 5329-3027
Document créé le 01/09/06 00:42, dernière modification le Vendredi 17 Juin 2011, 12:12
Source du document imprimé : http://www.gaudry.be/java-api-rf-javax/swing/filechooser/FileSystemView.html Document affiché 1 fois ce mois de Juin.
St.Gaudry©07.01.02
Outils (masquer)
||
Recherche (afficher)
Recherche :

Utilisateur (masquer)
Apparence (afficher)
Stats (afficher)
15832 documents
452 astuces.
549 niouzes.
3099 definitions.
447 membres.
8115 messages.

Document genere en :
0,52 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
Réfléchis, décide et agis!

Marc Levy [Extrait de Et si c'était vrai...]
 
l'infobrol
Nous sommes le Samedi 02 Juin 2012, 04:54, toutes les heures sont au format GMT+1.00 Heure, heure d'été (+1)