| Modifier and Type | Class and Description |
|---|---|
| public static class | CommonDialogs.
Provides a mechanism to filter different kinds of file name extensions. |
| public static class | CommonDialogs.
An object representing the result of showing a file chooser dialog. |
| public static class | CommonDialogs.
Available file chooser types. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private static String | |
| private static String | |
| protected static CommonDialogs. | createFileChooserResult(String[] files, CommonDialogs.
|
| public static CommonDialogs. | Returns: the files that the user selects and the selected extension filter. If the user cancels the file chooser, the method returns empty results object.the owner window for this file chooser (may be null) owner, File the initial folder, may be folder, String nullthe initial file name for a SAVE dialog (may be null) filename, String the title of the file chooser title, int the type of the file chooser, one of the constants from type, boolean Typeenables or disable multiple file selections multipleMode, List<CommonDialogs.the filters of the file chooser extensionFilters,the zero-based index of the filter selected by default defaultFilterIndex)Creates a native file chooser that lets the user select files. |
| public static File | Returns: the folder that the user selects. If the user cancels the folder chooser, the method returns null.the owner window for this folder chooser (may be null) owner, File the initial folder, may be folder, String nullthe title of the folder chooser title)Creates a native folder chooser that lets the user selects folder. |
| CommonDialogs | back to summary |
|---|---|
| private CommonDialogs() | |
| convertFolder | back to summary |
|---|---|
| private static String convertFolder(File folder) | |
| convertTitle | back to summary |
|---|---|
| private static String convertTitle(String title) | |
| createFileChooserResult | back to summary |
|---|---|
| protected static CommonDialogs. | |
| showFileChooser | back to summary |
|---|---|
| public static CommonDialogs. Creates a native file chooser that lets the user select files.
| |
| showFolderChooser | back to summary |
|---|---|
| public static File showFolderChooser(Window owner, File folder, String title) Creates a native folder chooser that lets the user selects folder. | |
ExtensionFilter that will show
txt files:
List extensions = new ArrayList();
extensions.add("*.txt");
ExtensionFilter filter = new ExtensionFilter("Text files", extensions);
List filters = new ArrayList();
filters.add(filters);
FileChooser.show(..., filters);
showFileChooser
| Modifier and Type | Field and Description |
|---|---|
| private final String | |
| private final List |
| Access | Constructor and Description |
|---|---|
| public | ExtensionFilter(String
the textual description for the filter description, List<String> the accepted file name extensions extensions)Creates an |
| Modifier and Type | Method and Description |
|---|---|
| private String[] | |
| public String | |
| public List |
| description | back to summary |
|---|---|
| private final String description | |
| extensions | back to summary |
|---|---|
| private final List<String> extensions | |
| ExtensionFilter | back to summary |
|---|---|
| public ExtensionFilter(String description, List<String> extensions) Creates an
| |
| extensionsToArray | back to summary |
|---|---|
| private String[] extensionsToArray() | |
| getDescription | back to summary |
|---|---|
| public String getDescription() | |
| getExtensions | back to summary |
|---|---|
| public List | |
| Modifier and Type | Field and Description |
|---|---|
| private final List | |
| private final CommonDialogs. |
| Access | Constructor and Description |
|---|---|
| public | FileChooserResult(List<File>
should not be null, may be an empty list files, CommonDialogs.Creates a new result object. |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public CommonDialogs. | getExtensionFilter()
Returns the ExtensionFilter selected by a user when a file chooser dialog is closed. |
| public List |
| files | back to summary |
|---|---|
| private final List<File> files | |
| filter | back to summary |
|---|---|
| private final CommonDialogs. | |
| FileChooserResult | back to summary |
|---|---|
| public FileChooserResult(List<File> files, CommonDialogs. Creates a new result object. | |
| FileChooserResult | back to summary |
|---|---|
| public FileChooserResult() Creates an empty results object. Used when a user cancels a file chooser dialog. | |
| getExtensionFilter | back to summary |
|---|---|
| public CommonDialogs. Returns the ExtensionFilter selected by a user when a file chooser dialog is closed. A reference to one of the extension filter objects passed to the showFileChooser() method. May be null. | |
| getFiles | back to summary |
|---|---|
| public List Returns a list of selected files.
If a user cancels the dialog then this list is empty.
Note that in case of a SAVE dialog the file name extension
corresponding to the selected ExtensionFilter may not be appended
automatically. Client code is responsible for checking the file
name and appending the extension if needed. Use | |
showFileChooser
| Modifier and Type | Field and Description |
|---|---|
| public static final int | |
| public static final int |
| Access | Constructor and Description |
|---|---|
| public |
| OPEN | back to summary |
|---|---|
| public static final int OPEN
| |
| SAVE | back to summary |
|---|---|
| public static final int SAVE
| |
| Type | back to summary |
|---|---|
| public Type() | |