FileDialog class displays a dialog window
from which the user can select a file.
Since it is a modal dialog, when the application calls
its show method to display the dialog,
it blocks the rest of the application until the user has
chosen a file.
This means that Dialog#setModalityType(ModalityType) may be ignored.
Window#show
| Modifier and Type | Field and Description |
|---|---|
| private static final String | base
Hides java. |
| pack-priv String | dir
The string specifying the directory to display in the file dialog. |
| pack-priv String | file
The string specifying the initial value of the filename text field in the file dialog. |
| private File[] | files
Contains the File instances for all the files that the user selects. |
| pack-priv FilenameFilter | filter
The filter used as the file dialog's filename filter. |
| public static final int | LOAD
This constant value indicates that the purpose of the file dialog window is to locate a file from which to read. |
| pack-priv int | mode
There are two |
| private boolean | multipleMode
Represents whether the file dialog allows the multiple file selection. |
| private static int | |
| public static final int | SAVE
This constant value indicates that the purpose of the file dialog window is to locate a file to which to write. |
| private static final long | serialVersionUID
Use serialVersionUID from JDK 1.1 for interoperability.
|
| Access | Constructor and Description |
|---|---|
| public | |
| public | FileDialog(Frame
the owner of the dialog parent, String the title of the dialog title)Creates a file dialog window with the specified title for loading a file. |
| public | FileDialog(Frame
the owner of the dialog parent, String the title of the dialog title, int the mode of the dialog; either
mode)FileDialog.LOAD or FileDialog.SAVECreates a file dialog window with the specified title for loading or saving a file. |
| public | |
| public | FileDialog(Dialog
the owner of the dialog parent, String the title of the dialog; a title)null value
will be accepted without causing a
NullPointerException to be thrownCreates a file dialog window with the specified title for loading a file. |
| public | FileDialog(Dialog
the owner of the dialog parent, String the title of the dialog; a title, int null value
will be accepted without causing a
NullPointerException to be thrownthe mode of the dialog; either
mode)FileDialog.LOAD or FileDialog.SAVECreates a file dialog window with the specified title for loading or saving a file. |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| pack-priv String | constructComponentName()
Overrides java. Constructs a name for this component. |
| public String | Returns: the (potentiallynull or invalid)
directory of this FileDialogGets the directory of this file dialog. |
| public String | Returns: the currently selected file of this file dialog window, ornull if none is selectedGets the selected file of this file dialog. |
| public FilenameFilter | Returns: this file dialog's filename filterDetermines this file dialog's filename filter. |
| public File[] | Returns: files that the user selects or an empty array if the user cancels the file dialog.Returns files that the user selects. |
| public int | Returns: the mode of this file dialog window, eitherFileDialog.LOAD or
FileDialog.SAVEIndicates whether this file dialog box is for loading from a file or for saving to a file. |
| public boolean | Returns: true if the file dialog allows the multiple
file selection; false otherwise.Returns whether the file dialog allows the multiple file selection. |
| protected String | Returns: the parameter string of this file dialog windowOverrides java. Returns a string representing the state of this |
| pack-priv boolean | |
| private void | readObject(ObjectInputStream
the s)ObjectInputStream to readHides java. Reads the |
| public void | setDirectory(String
the specified directory dir)Sets the directory of this file dialog window to be the specified directory. |
| public void | |
| public synchronized void | setFilenameFilter(FilenameFilter
the specified filter filter)Sets the filename filter for this file dialog window to the specified filter. |
| private void | |
| public void | setMode(int
the mode for this file dialog, either
mode)FileDialog.LOAD or
FileDialog.SAVESets the mode of the file dialog. |
| public void | setMultipleMode(boolean
if enable)true, multiple file selection is enabled;
false - disabled.Enables or disables multiple file selection for the file dialog. |
| public void |
| base | back to summary |
|---|---|
| private static final String base Hides java. | |
| dir | back to summary |
|---|---|
| pack-priv String dir The string specifying the directory to display
in the file dialog. This variable may be
| |
| file | back to summary |
|---|---|
| pack-priv String file The string specifying the initial value of the
filename text field in the file dialog.
This variable may be | |
| files | back to summary |
|---|---|
| private File[] files Contains the File instances for all the files that the user selects.
| |
| filter | back to summary |
|---|---|
| pack-priv FilenameFilter filter The filter used as the file dialog's filename filter.
The file dialog will only be displaying files whose
names are accepted by this filter.
This variable may be
| |
| LOAD | back to summary |
|---|---|
| public static final int LOAD This constant value indicates that the purpose of the file dialog window is to locate a file from which to read. | |
| mode | back to summary |
|---|---|
| pack-priv int mode There are two | |
| multipleMode | back to summary |
|---|---|
| private boolean multipleMode Represents whether the file dialog allows the multiple file selection.
| |
| nameCounter | back to summary |
|---|---|
| private static int nameCounter Hides java. | |
| SAVE | back to summary |
|---|---|
| public static final int SAVE This constant value indicates that the purpose of the file dialog window is to locate a file to which to write. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides java. Use serialVersionUID from JDK 1.1 for interoperability. | |
| FileDialog | back to summary |
|---|---|
| public FileDialog(Frame parent) Creates a file dialog for loading a file. The title of the
file dialog is initially empty. This is a convenience method for
Note Some platforms may not support showing the user-specified title in a file dialog. In this situation, either no title will be displayed in the file dialog's title bar or, on some systems, the file dialog's title bar will not be displayed.
| |
| FileDialog | back to summary |
|---|---|
| public FileDialog(Frame parent, String title) Creates a file dialog window with the specified title for loading
a file. The files shown are those in the current directory.
This is a convenience method for
Note Some platforms may not support showing the user-specified title in a file dialog. In this situation, either no title will be displayed in the file dialog's title bar or, on some systems, the file dialog's title bar will not be displayed. | |
| FileDialog | back to summary |
|---|---|
| public FileDialog(Frame parent, String title, int mode) Creates a file dialog window with the specified title for loading or saving a file.
If the value of Note Some platforms may not support showing the user-specified title in a file dialog. In this situation, either no title will be displayed in the file dialog's title bar or, on some systems, the file dialog's title bar will not be displayed.
| |
| FileDialog | back to summary |
|---|---|
| public FileDialog(Dialog parent) Creates a file dialog for loading a file. The title of the
file dialog is initially empty. This is a convenience method for
Note Some platforms may not support showing the user-specified title in a file dialog. In this situation, either no title will be displayed in the file dialog's title bar or, on some systems, the file dialog's title bar will not be displayed.
| |
| FileDialog | back to summary |
|---|---|
| public FileDialog(Dialog parent, String title) Creates a file dialog window with the specified title for loading
a file. The files shown are those in the current directory.
This is a convenience method for
Note Some platforms may not support showing the user-specified title in a file dialog. In this situation, either no title will be displayed in the file dialog's title bar or, on some systems, the file dialog's title bar will not be displayed.
| |
| FileDialog | back to summary |
|---|---|
| public FileDialog(Dialog parent, String title, int mode) Creates a file dialog window with the specified title for loading or saving a file.
If the value of Note Some platforms may not support showing the user-specified title in a file dialog. In this situation, either no title will be displayed in the file dialog's title bar or, on some systems, the file dialog's title bar will not be displayed.
| |
| addNotify | back to summary |
|---|---|
| public void addNotify() Overrides java. Creates the file dialog's peer. The peer allows us to change the look of the file dialog without changing its functionality. | |
| constructComponentName | back to summary |
|---|---|
| pack-priv String constructComponentName() Overrides java. Constructs a name for this component. Called by | |
| getDirectory | back to summary |
|---|---|
| public String getDirectory() Gets the directory of this file dialog.
| |
| getFile | back to summary |
|---|---|
| public String getFile() Gets the selected file of this file dialog. If the user
selected
It is platform-specific as to what happens for
| |
| getFilenameFilter | back to summary |
|---|---|
| public FilenameFilter getFilenameFilter() Determines this file dialog's filename filter. A filename filter allows the user to specify which files appear in the file dialog window. Filename filters do not function in Sun's reference implementation for Microsoft Windows.
| |
| getFiles | back to summary |
|---|---|
| public File[] getFiles() Returns files that the user selects. If the user cancels the file dialog, then the method returns an empty array.
| |
| getMode | back to summary |
|---|---|
| public int getMode() Indicates whether this file dialog box is for loading from a file or for saving to a file.
| |
| isMultipleMode | back to summary |
|---|---|
| public boolean isMultipleMode() Returns whether the file dialog allows the multiple file selection.
| |
| paramString | back to summary |
|---|---|
| protected String paramString() Overrides java. Returns a string representing the state of this
| |
| postsOldMouseEvents | back to summary |
|---|---|
| pack-priv boolean postsOldMouseEvents() Overrides java. | |
| readObject | back to summary |
|---|---|
| private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException Hides java. Reads the
| |
| setDirectory | back to summary |
|---|---|
| public void setDirectory(String dir) Sets the directory of this file dialog window to be the
specified directory. Specifying a
Specifying "" as the directory is exactly equivalent to
specifying
| |
| setFile | back to summary |
|---|---|
| public void setFile(String file) Sets the selected file for this file dialog window to be the specified file. This file becomes the default file if it is set before the file dialog window is first shown. When the dialog is shown, the specified file may be pre-selected. The visible manifestation of this selection, if any, depends on factors such as the file existence, the dialog mode, and the native platform. For example, the file could be highlighted in the file list, or a file name editbox could be populated with the file name.
This method accepts either a full file path, or a file name with an
extension if used together with the
Appearance and behaviours may also differ between
It is also platform-specific as to what happens for
Specifying "" as the file is exactly equivalent to specifying
| |
| setFilenameFilter | back to summary |
|---|---|
| public synchronized void setFilenameFilter(FilenameFilter filter) Sets the filename filter for this file dialog window to the specified filter. Filename filters do not function in Sun's reference implementation for Microsoft Windows.
| |
| setFiles | back to summary |
|---|---|
| private void setFiles(File[] files) Stores the names of all the files that the user selects. Note that the method is private and it's intended to be used by the peers through the AWTAccessor API. | |
| setMode | back to summary |
|---|---|
| public void setMode(int mode) Sets the mode of the file dialog. If
| |
| setMultipleMode | back to summary |
|---|---|
| public void setMultipleMode(boolean enable) Enables or disables multiple file selection for the file dialog.
Multiple mode may be ignored in some cases, for example, commonly
| |
| setTitle | back to summary |
|---|---|
| public void setTitle(String title) Overrides java. Doc from java. Sets the title of the Dialog. Note Some platforms may not support showing the user-specified title in a file dialog. In this situation, either no title will be displayed in the file dialog's title bar or, on some systems, the file dialog's title bar will not be displayed.
| |