Java Reference
In-Depth Information
if (icon.getIconHeight() > PREFERRED_HEIGHT) {
icon = new ImageIcon(icon.getImage().getScaledInstance(
-1, PREFERRED_HEIGHT, Image.SCALE_DEFAULT));
}
}
setIcon(icon);
}
}
}
}
Using the FileSystemView Class
The
FileSystemView
class localizes access to platform-specific file system information. Where
the JDK 1.1 version of
java.io.File
was fairly crippled in this respect,
FileSystemView
fills in to
make it easier to design
FileChooserUI
objects. The Swing
FileSystemView
class provides three
custom views as package-private subclasses of
FileSystemView
. They include support for UNIX
and Windows, plus a generic handler.
Although it isn't necessary to define your own
FileSystemView
, the class provides some
features that can be useful outside the context of a
JFileChooser
. To get the view specific to the
user's runtime environment, call
public static FileSystemView getFileSystemView()
. The
class definition follows.
public abstract class FileSystemView {
// Constructors
public FileSystemView(); // Properties
// Properties
public File getDefaultDirectory();
public File getHomeDirectory();
public File[] getRoots();
// Class Methods
public static FileSystemView getFileSystemView();
// Other Methods
public File createFileObject(File directory, String filename);
public File createFileObject(String path);
protected File createFileSystemRoot(File file);
public abstract File createNewFolder(File containingDir) throws IOException;
public File getChild(File parent, String filename);
public File[] getFiles(File directory, boolean useFileHiding);
public File getParentDirectory(File file);
public String getSystemDisplayName(File file);
public Icon getSystemIcon(File file);
public String getSystemTypeDescription(File file);
public boolean isComputerNode(File file);
public boolean isDrive(File file);
public boolean isFileSystem(File file);
public boolean isFileSystemRoot(File file);
public boolean isFloppyDrive(File file);