Java Reference
In-Depth Information
Recall that a single backslash inside quoted strings is an escape character that is
combined with another character to form a special meaning, such as
\n
for a
newline character. The \\ combination denotes a single backslash.
When a user supplies a file name to a program, however, the user should not type
the backslash twice.
A
DVANCED
T
OPIC
11.1: File Dialog Boxes
In a program with a graphical user interface, you will want to use a file dialog box
(such as the one shown in the figure below) whenever the users of your program
need to pick a file. The
JFileChooser
class implements a file dialog box for
the Swing user interface toolkit.
The
JFileChooser
dialog box allows users to select a file by navigating
through directories.
500
501
A
JFileChooser
Dialog Box
The
JFileChooser
class relies on another class,
File
, which describes disk
files and directories. For example,