
CHAPTER 27
Thejavax.swing.filechooser Package
The javax.swing .filechooser package defines auxiliary classes used by the javax.-
swing .JFileChooser component. You can customize the behavior of a JF ileChooser by
defining concrete subclasses of these abstract classes. Define a FileF ilter to specify
what files should be displayed by the JF ileChooser. Define a FileV iew to specify how
it should display those classes. And define a FileSystemV iew to specify how it should
traverse the file system. Figure 27-1 shows the class hierarchy of this package.
ABSTRACT CLASS
extends
KEY
CLASS
javax.swing.filechooser
java.lang
Object
FileFilter
FileSystemView
FileView
Figur e 27−1: The javax.swing.filechooser package
FileF ilter Ja va 1.2
javax.swing .filechooser
This abstract class defines the methods used by the JF ileChooser component to select a
subset of files for display. When the accept() method is passed a File object, it should
retur n tr ue if that file should be displayed by the JF ileChooser and false otherwise. accept()
often makes its determination based on the filename extension, but it can also take
other factors into account, such as the readability and writability of the file. The getDe-
scription() method must retur nahuman-r eadable description (preferably localized for
the current locale) of the filtering operation perfor med by the filter. For example, if a
javax.swing.
filechooser
551
14 September 1999 10:28