A file chooser can be customized in a number of ways. (Several of these modifications are shown in Figure 5-7.) Most of the modifications are of the sort that one normally sees with GUI components, such as changing the string in the file chooser's title bar or setting button mnemonics. Certain customizations are more specific to the file chooser, however, and deserve special mention.
Although the most common use for a file chooser is to open or save files, XFileChooser allows you to select a file for any other action you specify. To this end, a "generic" method for bringing up a file chooser window, showDialog(), is provided in addition to showOpenDialog() and showSaveDialog(). (Since the file chooser itself doesn't affect files, the only difference between a custom dialog and the others is the title on the dialog window and the label on the "accept" button.)
As with the JFileChooser, three types of file filtering are available to the application in bringing up a file chooser:
Built-in filtering. Currently this is limited to showing hidden files or not (using the setFileHidingEnabled() method). Since the underlying Extended File API does not handle invisible files, this filter only checks to see if the filename begins with a `.' (period), signifying a hidden file on UNIX systems.
Application-controlled filtering, whereby the file chooser shows only files that the filter -- some instance of FileFilterapi) -- allows. For example, you may want your application to only open files with a particular suffix.
User-choosable filters. In this scenario, the file chooser presents the user with selection of filters to apply to the file chooser. An example of this is shown in"Filtering Files".
The FileView is the way each file is shown in the file chooser's list of files. By default a small icon and the file's name appear; this can be customized, for example, to show a unique icon next to each filename. An example of this is shown in "Modifying the FileView".
An accessory is a component that is invoked in the file chooser when a file is selected. One example of an accessory might be a panel with controls in it. Another might be a small preview area in the file chooser that displays a thumbnail of a selected graphic file. An example of this kind of customization is given in "Setting the Accessory".