Instances of this class allow the user to navigate the file system and select or enter a file name.
Note: Only one of the styles SAVE and OPEN may be specified.
IMPORTANT: This class is not intended to be subclassed.
Constructs a new instance of this class given only its parent.
| name | type | description |
|---|---|---|
| parent | org.eclipse.swt.widgets.Shell | a shell which will be the parent of the new instance |
| IllegalArgumentException |
|
|
| SWTException |
|
|
Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.
The style value is either one of the style constants defined in
class SWT which is applicable to instances of this
class, or must be built by bitwise OR'ing together
(that is, using the int "|" operator) two or more
of those SWT style constants. The class description
lists the style constants that are applicable to the class.
Style bits are also inherited from superclasses.
| name | type | description |
|---|---|---|
| parent | org.eclipse.swt.widgets.Shell | a shell which will be the parent of the new instance |
| style | int | the style of dialog to construct |
| IllegalArgumentException |
|
|
| SWTException |
|
|
getFileName() · also: get_file_nameReturns the path of the first file that was selected in the dialog relative to the filter path, or an empty string if no such file has been selected.
Returns: the relative path of the file
setFileName(String string) · also: set_file_nameSet the initial filename which the dialog will select by default when opened to the argument, which may be null. The name will be prefixed with the filter path when one is supplied.
| name | type | description |
|---|---|---|
| string | String | the file name |
getFileNames() · also: get_file_namesReturns a (possibly empty) array with the paths of all files that were selected in the dialog relative to the filter path.
Returns: the relative paths of the files
getFilterExtensions() · also: get_filter_extensionsReturns the file extensions which the dialog will use to filter the files it shows.
Returns: the file extensions filter
setFilterExtensions(String[] extensions) · also: set_filter_extensionsSet the file extensions which the dialog will use to filter the files it shows to the argument, which may be null.
The strings are platform specific. For example, on some platforms, an extension filter string is typically of the form "*.extension", where "*.*" matches all files. For filters with multiple extensions, use semicolon as a separator, e.g. "*.jpg;*.png".
Note: On Mac, setting the file extension filter affects how app bundles are treated by the dialog. When a filter extension having the app extension (.app) is selected, bundles are treated as files. For all other extension filters, bundles are treated as directories. When no filter extension is set, bundles are treated as files.
| name | type | description |
|---|---|---|
| extensions | String[] | the file extension filter |
getFilterIndex() · also: get_filter_indexGet the 0-based index of the file extension filter which was selected by the user, or -1 if no filter was selected.
This is an index into the FilterExtensions array and the FilterNames array.
Returns: index the file extension filter index
setFilterIndex(int index) · also: set_filter_indexSet the 0-based index of the file extension filter which the dialog will use initially to filter the files it shows to the argument.
This is an index into the FilterExtensions array and the FilterNames array.
| name | type | description |
|---|---|---|
| index | int | the file extension filter index |
getFilterNames() · also: get_filter_namesReturns the names that describe the filter extensions which the dialog will use to filter the files it shows.
Returns: the list of filter names
setFilterNames(String[] names) · also: set_filter_namesSets the names that describe the filter extensions which the dialog will use to filter the files it shows to the argument, which may be null.
Each name is a user-friendly short description shown for
its corresponding filter. The names array must
be the same length as the extensions array.
| name | type | description |
|---|---|---|
| names | String[] | the list of filter names, or null for no filter names |
getFilterPath() · also: get_filter_pathReturns the directory path that the dialog will use, or an empty string if this is not set. File names in this path will appear in the dialog, filtered according to the filter extensions.
Returns: the directory path string
setFilterPath(String string) · also: set_filter_pathSets the directory path that the dialog will use to the argument, which may be null. File names in this path will appear in the dialog, filtered according to the filter extensions. If the string is null, then the operating system's default filter path will be used.
Note that the path string is platform dependent. For convenience, either '/' or '\' can be used as a path separator.
| name | type | description |
|---|---|---|
| string | String | the directory path |
open()Makes the dialog visible and brings it to the front of the display.
Returns: a string describing the absolute path of the first selected file, or null if the dialog was cancelled or an error occurred
| SWTException |
|
|
openDialog()Makes the dialog visible and brings it to the front of the display.
Equal to FileDialog#open() but also exposes for state information like user cancellation.
Returns: an Optional that either contains the absolute path of the first selected file or is empty in case the dialog was canceled
| SWTException |
|
|
getOverwrite() · also: get_overwriteReturns the flag that the dialog will use to determine whether to prompt the user for file overwrite if the selected file already exists.
Returns: true if the dialog will prompt for file overwrite, false otherwise
setOverwrite(boolean overwrite) · also: set_overwriteSets the flag that the dialog will use to determine whether to prompt the user for file overwrite if the selected file already exists.
Note: On some platforms where suppressing the overwrite prompt is not supported, the prompt is shown even when invoked with overwrite false.
| name | type | description |
|---|---|---|
| overwrite | boolean | true if the dialog will prompt for file overwrite, false otherwise |
Returns the receiver's parent, which must be a Shell
or null.
Returns: the receiver's parent
| SWTException |
|
|
getStyle() · also: get_styleReturns the receiver's style information.
Note that, the value which is returned by this method may not match the value which was provided to the constructor when the receiver was created.
Returns: the style bits
| SWTException |
|
|
getText() · also: get_textReturns the receiver's text, which is the string that the window manager will typically display as the receiver's title. If the text has not previously been set, returns an empty string.
Returns: the text
| SWTException |
|
|
setText(String string) · also: set_textSets the receiver's text, which is the string that the window manager will typically display as the receiver's title, to the argument, which must not be null.
| name | type | description |
|---|---|---|
| string | String | the new text |
| IllegalArgumentException |
|
|
| SWTException |
|
|