Java Reference
In-Depth Information
Table 9-9.
JColorChooser UIResource Elements (Continued)
Property String
Object Type
ColorChooser.swatchesRecentText
String
ColorChooser.swatchesSwatchSize
Dimension
ColorChooserUI
String
JFileChooser Class
The Swing component set also provides a chooser for the selection of file names and/or direc-
tories: the
JFileChooser
class. This chooser replaces the need for using the
FileDialog
from the
original AWT component set. Like the other Swing chooser components,
JFileChooser
isn't
automatically placed in a pop-up window, but it can be placed anywhere within the user interface
of your program. Figure 9-25 shows a
JFileChooser
with the Metal look and feel, Ocean theme,
that has been automatically placed in a modal
JDialog
.
Figure 9-25.
JFileChooser sample
In support of the
JFileChooser
class are a handful of classes in the
javax.swing.filechooser
package. The support classes include a
FileFilter
class for restricting files and directories to
be listed in the
FileView
of the
JFileChooser
. The
FileView
controls how the directories and
files are listed within the
JFileChooser
. The
FileSystemView
is an abstract class that tries to hide
file system-related operating system specifics from the file chooser. Java 2 platform vendors
will provide operating system-specific versions so that tasks such as listing root partitions can
be done (with 100% Pure Java code).